From 34ce3a6a9bb91bcd704e46680cae7fd52b37d64f Mon Sep 17 00:00:00 2001 From: "marco.locatelli" Date: Wed, 20 Sep 2023 16:26:09 +0200 Subject: [PATCH] PrimoCommit --- CheckGitlabCommits.ps1 | 165 +++++++++++++++++++++++++++++++ CheckGitlabMirroring.ps1 | 157 +++++++++++++++++++++++++++++ CheckGitlabPipelines.ps1 | 159 +++++++++++++++++++++++++++++ CheckGitlabProtectedBranches.ps1 | 137 +++++++++++++++++++++++++ GPW_CheckProj_office.ps1 | 109 ++++++++++++++++++++ GPW_CheckScadenzeLic.ps1 | 69 +++++++++++++ GPW_CheckTimb_office.ps1 | 108 ++++++++++++++++++++ GPW_StartApps_office.ps1 | 84 ++++++++++++++++ TEST_SENDER.ps1 | 37 +++++++ TestCall.ps1 | 9 ++ WDC_SyncWebCompo.ps1 | 78 +++++++++++++++ syncFileUpload.bat | 4 + 12 files changed, 1116 insertions(+) create mode 100644 CheckGitlabCommits.ps1 create mode 100644 CheckGitlabMirroring.ps1 create mode 100644 CheckGitlabPipelines.ps1 create mode 100644 CheckGitlabProtectedBranches.ps1 create mode 100644 GPW_CheckProj_office.ps1 create mode 100644 GPW_CheckScadenzeLic.ps1 create mode 100644 GPW_CheckTimb_office.ps1 create mode 100644 GPW_StartApps_office.ps1 create mode 100644 TEST_SENDER.ps1 create mode 100644 TestCall.ps1 create mode 100644 WDC_SyncWebCompo.ps1 create mode 100644 syncFileUpload.bat diff --git a/CheckGitlabCommits.ps1 b/CheckGitlabCommits.ps1 new file mode 100644 index 0000000..fe5ee39 --- /dev/null +++ b/CheckGitlabCommits.ps1 @@ -0,0 +1,165 @@ +################START SCRIPT################ + +#rilevo time per log inizio analisi +$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +# avvio stopwatch +$mainStopWatch = [system.diagnostics.stopwatch]::StartNew() + +#token per autenticazione +$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"} + +#contatore ciclo do while +$projectCount = 1 + +#numero massimo di progetti da analizzare +$projectNumber = 200 + +#conteggio progetti trovati +$projectsFound = 0 + +#conteggio progetti con commit negli ultimi giorni +$projectWithCommits = 0 + +#conteggio progetti senza commit negli ultimi giorni +$projectWithNoCommits = 0 + +#conteggio commits degli ultimi giorni +$recentCommits = 0 + +#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso +$logLevel = 0 + +#output a terminale: 0=disattivo, 1=abilitato +$terminalOutput = 0 + +#ultimi giorni da considerare +$lastDays = 7 + +#data per conteggio commits degli ultimi giorni +$requestDate = (Get-Date).AddDays(-$lastDays).toString("yyyy-MM-dd") + +#cartella file di log +$GitLogFolder="c:\Steamware\Logs\Gitlab\" + +#nome file di log +$logFile = Join-Path $GitLogFolder "GitlabCommits.log" + +#dichiaro funzione per scrittura output +Function WriteLogOutput +{ + Param ($logType, [string]$logString) + #scrivo su file la stringa se il tipo di log è > o = al livello di log richieeso + if($logType -le $logLevel) + { + Add-content $logFile -value "$logString" + #scrivo su terminale la stringa se $terminalOutput=1 + if($terminalOutput -eq 1) + { + Write-Output($logString) + } + } +} + +#creazione folder di Log se non già esistente +if (Test-Path $GitLogFolder) +{ +} +else +{ + New-Item $GitLogFolder -ItemType Directory +} + +#scrivo intestazione e inizio analisi +WriteLogOutput 0 "--------------------" +Switch ($logLevel) +{ + 0 {WriteLogOutput 0 "LOG SINTETICO GITLAB COMMITS"} + 1 {WriteLogOutput 0 "LOG ERRORI GITLAB COMMITS"} + 2 {WriteLogOutput 0 "LOG FULL GITLAB COMMITS"} + 3 {WriteLogOutput 0 "LOG AMPOLLOSO GITLAB COMMITS"} +} +WriteLogOutput 0 "" +WriteLogOutput 0 "Percorso log: $GitLogFolder" +WriteLogOutput 0 "" +WriteLogOutput 0 "Inizio Esecuzione Script: $startTime" +WriteLogOutput 0 "" +WriteLogOutput 0 "RICERCA DA $requestDate | ULTIMI $lastDays GIORNI" + +#ciclo principale do/while che cicla da 1 a N projectNumber +do +{ + $callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/repository/commits?per_page=100&since=" + $requestDate + try + { + $Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing + $parsedResponse = $Response.Content | ConvertFrom-Json + #scrivo il numero del progetto nel terminale e su file + WriteLogOutput 1 "" + WriteLogOutput 1 "--------------------" + WriteLogOutput 1 "**PROGETTO $projectCount**" + if($parsedResponse.Count -eq 0 ) + { + $projectWithNoCommits=$projectWithNoCommits+1 + } + else + { + $projectWithCommits=$projectWithCommits+1 + foreach($item in $parsedResponse) + { + if($item.web_url) + { + WriteLogOutput 1 "Date: $($item.committed_date) - Web Url: $($item.web_url)" + $recentCommits=$recentCommits+1 + } + } + } + $projectsFound=$projectsFound+1 + } + #scrivo se trovo un errore (in particolare progetto non trovato o privo di commits) durante il try/catch (solo se loglevel è = 3) + catch + { + WriteLogOutput 3 "" + WriteLogOutput 3 "--------------------" + WriteLogOutput 3 "**PROGETTO $projectCount NON ESISTENTE**" + } + $projectCount=$projectCount+1 +} +#fine ciclo principale +while($projectCount -le $projectNumber) + +#percentuale di projectWithCommits sul totale +$projectWithCommitsPercentage = [math]::Round(($projectWithCommits/$projectsFound)*100,1) + +#percentuale di projectWithNoCommits sul totale +$projectWithNoCommitsPercentage = [math]::Round(($projectWithNoCommits/$projectsFound)*100,1) + +# fermo stopwatch e calcolo durata script +$mainStopWatch.Stop() +$durataScript = $mainStopWatch.Elapsed.TotalSeconds + +#rilevo time per log fine analisi +$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +#invio a zabbix le metriche rilevate tramite zabbix_sender.exe +WriteLogOutput 0 "" +#& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ProjectsFound -o $projectsFound +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.LastDaysCommits -o $lastDays +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.RecentCommits -o $recentCommits +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ProjectWithCommits -o $projectWithCommits +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ProjectWithNoCommits -o $projectWithNoCommits +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ProjectWithCommitsPercentage -o $projectWithCommitsPercentage +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ProjectWithNoCommitsPercentage -o $projectWithNoCommitsPercentage +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.CheckCommitsDuration -o $durataScript + +#scrivo a video le statistiche +WriteLogOutput 0 "" +WriteLogOutput 0 "PROGETTI TOTALI: $projectsFound" +WriteLogOutput 0 "COMMITS TOTALI: $recentCommits" +WriteLogOutput 0 "PROGETTI CON COMMITS: $projectWithCommits ($projectWithCommitsPercentage%)" +WriteLogOutput 0 "PROGETTI SENZA COMMITS: $projectWithNoCommits ($projectWithNoCommitsPercentage%)" +WriteLogOutput 0 "" +WriteLogOutput 0 "Fine Esecuzione Script: $endTime" +WriteLogOutput 0 "" +WriteLogOutput 0 "Durata Esecuzione Script: $durataScript secondi" +WriteLogOutput 0 "" \ No newline at end of file diff --git a/CheckGitlabMirroring.ps1 b/CheckGitlabMirroring.ps1 new file mode 100644 index 0000000..7d9c3ab --- /dev/null +++ b/CheckGitlabMirroring.ps1 @@ -0,0 +1,157 @@ +################START SCRIPT################ + +#rilevo time per log inizio analisi +$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +# avvio stopwatch +$mainStopWatch = [system.diagnostics.stopwatch]::StartNew() + +#token per autenticazione +$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"} + +#contatore ciclo do while +$projectCount = 1 + +#numero massimo di progetti da analizzare +$projectNumber = 200 + +#conteggio progetti trovati +$existingProjects = 0 + +#conteggio mirroring in errore +$mirrorErrorsCount = 0 + +#conteggio mirroring riusciti +$mirrorSuccessCount = 0 + +#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso +$logLevel = 0 + +#output a terminale: 0=disattivo, 1=abilitato +$terminalOutput = 0 + +#cartella file di log +$GitLogFolder="c:\Steamware\Logs\Gitlab\" + +#nome file di log +$logFile = Join-Path $GitLogFolder "GitlabMirroring.log" + +#dichiaro funzione per scrittura output +Function WriteLogOutput +{ + Param ($logType, [string]$logString) + if($logType -le $logLevel) + { + #scrivo su file la stringa + Add-content $logFile -value "$logString" + #scrivo su terminale la stringa se $terminalOutput=1 + if($terminalOutput -eq 1){ + Write-Output($logString) + } + } +} + +#creazione folder di Log se non già esistente +if (Test-Path $GitLogFolder) +{ +} +else +{ + New-Item $GitLogFolder -ItemType Directory +} + +#scrivo intestazione e inizio analisi +WriteLogOutput 0 "--------------------" +Switch ($logLevel) +{ + 0 {WriteLogOutput 0 "LOG SINTETICO GITLAB MIRRORING"} + 1 {WriteLogOutput 0 "LOG ERRORI GITLAB MIRRORING"} + 2 {WriteLogOutput 0 "LOG FULL GITLAB MIRRORING"} + 3 {WriteLogOutput 0 "LOG AMPOLLOSO GITLAB MIRRORING"} +} +WriteLogOutput 0 "" +WriteLogOutput 0 "Percorso log: $GitLogFolder" +WriteLogOutput 0 "" +WriteLogOutput 0 "Inizio Esecuzione Script: $startTime" + +#ciclo principale do/while che cicla da 1 a N projectNumber +do +{ + #chiamata api che restituisce informazioni sullo stato dei mirror + $callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors" + try + { + #parsing della risposta api convertita da json + $Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing + $parsedResponse = $Response.Content | ConvertFrom-Json + #scrivo il numero del progetto nel terminale e su file + WriteLogOutput 1 "" + WriteLogOutput 1 "--------------------" + WriteLogOutput 1 "**PROGETTO $projectCount**" + foreach($item in $parsedResponse) + { + #verifico se i mirroring trovati per il progetto corrente hanno status "finished" + if($item.update_status.Equals("finished")) + { + WriteLogOutput 2 "Mirror: $($item.url) - Status: $($item.update_status)" + $mirrorSuccessCount=$mirrorSuccessCount+1 + } + #i mirroring che non hanno status "finished" vengono loggati con relativo errore + else + { + WriteLogOutput 1 "Mirror: $($item.url) - Status: $($item.update_status)" + WriteLogOutput 1 "Error: $($item.last_error)" + $mirrorErrorsCount=$mirrorErrorsCount+1 + } + } + $existingProjects=$existingProjects+1 + } + #scrivo se trovo un errore (in particolare progetto ID non trovato) durante il try/catch + catch + { + WriteLogOutput 3 "" + WriteLogOutput 3 "--------------------" + WriteLogOutput 3 "**ERRORE: PROGETTO $projectCount NON ESISTENTE**" + } + $projectCount=$projectCount+1 +} +#fine ciclo principale +while($projectCount -le $projectNumber) + +#somma di mirrorSuccess e mirrorErrors +$mirrorCount = $mirrorSuccessCount+$mirrorErrorsCount + +#percentuale di mirrorSuccess sul totale +$mirrorSuccessPercentage = [math]::Round(($mirrorSuccessCount/$mirrorCount)*100,1) + +#percentuale di mirrorErrors sul totale +$mirrorErrorsPercentage = [math]::Round(($mirrorErrorsCount/$mirrorCount)*100,1) + +# fermo stopwatch e calcolo durata script +$mainStopWatch.Stop() +$durataScript = $mainStopWatch.Elapsed.TotalSeconds + +#rilevo time per log fine analisi +$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +#invio a zabbix le metriche rilevate tramite zabbix_sender.exe +WriteLogOutput 0 "" +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.Projects -o $existingProjects +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.TotalMirror -o $mirrorCount +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.SuccessMirror -o $mirrorSuccessCount +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ErrorsMirror -o $mirrorErrorsCount +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.SuccessMirrorPercent -o $mirrorSuccessPercentage +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ErrorsMirrorPercent -o $mirrorErrorsPercentage +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.CheckMirrorDuration -o $durataScript + +#scrivo a video le statistiche +WriteLogOutput 0 "" +WriteLogOutput 0 "PROGETTI ANALIZZATI: $existingProjects" +WriteLogOutput 0 "MIRRORING TOTALI: $mirrorCount" +WriteLogOutput 0 "MIRRORING RIUSCITI: $mirrorSuccessCount ($mirrorSuccessPercentage%)" +WriteLogOutput 0 "MIRRORING FALLITI: $mirrorErrorsCount ($mirrorErrorsPercentage%)" +WriteLogOutput 0 "" +WriteLogOutput 0 "Fine Esecuzione Script: $endTime" +WriteLogOutput 0 "" +WriteLogOutput 0 "Durata Esecuzione Script: $durataScript secondi" +WriteLogOutput 0 "" \ No newline at end of file diff --git a/CheckGitlabPipelines.ps1 b/CheckGitlabPipelines.ps1 new file mode 100644 index 0000000..28a2c06 --- /dev/null +++ b/CheckGitlabPipelines.ps1 @@ -0,0 +1,159 @@ +#DOCS: https://docs.gitlab.com/ee/api/pipelines.html + +#ESEMPIO: https://gitlab.steamware.net/api/v4/projects/12/pipelines + +################START SCRIPT################ + +#rilevo time per log inizio analisi +$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +# avvio stopwatch +$mainStopWatch = [system.diagnostics.stopwatch]::StartNew() + +#token per autenticazione +$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"} + +#contatore ciclo do while +$projectCount = 1 + +#numero massimo di progetti da analizzare +$projectNumber = 200 + +#conteggio progetti trovati +$projectsWithPipeline = 0 + +#conteggio pipeline in errore +$pipelineErrorsCount = 0 + +#conteggio pipeline riusciti +$pipelineSuccessCount = 0 + +#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso +$logLevel = 0 + +#output a terminale: 0=disattivo, 1=abilitato +$terminalOutput = 0 + +#cartella file di log +$GitLogFolder="c:\Steamware\Logs\Gitlab\" + +#nome file di log +$logFile = Join-Path $GitLogFolder "GitlabPipeline.log" + +#dichiaro funzione per scrittura output +Function WriteLogOutput +{ + Param ($logType, [string]$logString) + #scrivo su file la stringa se il tipo di log è > o = al livello di log richieeso + if($logType -le $logLevel) + { + Add-content $logFile -value "$logString" + #scrivo su terminale la stringa se $terminalOutput=1 + if($terminalOutput -eq 1) + { + Write-Output($logString) + } + } +} + +#creazione folder di Log se non già esistente +if (Test-Path $GitLogFolder) +{ +} +else +{ + New-Item $GitLogFolder -ItemType Directory +} + +#scrivo intestazione e inizio analisi +WriteLogOutput 0 "--------------------" +Switch ($logLevel) +{ + 0 {WriteLogOutput 0 "LOG SINTETICO GITLAB PIPELINE"} + 1 {WriteLogOutput 0 "LOG ERRORI GITLAB PIPELINE"} + 2 {WriteLogOutput 0 "LOG FULL GITLAB PIPELINE"} + 3 {WriteLogOutput 0 "LOG AMPOLLOSO GITLAB PIPELINE"} +} +WriteLogOutput 0 "" +WriteLogOutput 0 "Percorso log: $GitLogFolder" +WriteLogOutput 0 "" +WriteLogOutput 0 "Inizio Esecuzione Script: $startTime" + +#ciclo principale do/while che cicla da 1 a N projectNumber +do +{ + $callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/pipelines/latest" + try + { + $Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing + $parsedResponse = $Response.Content | ConvertFrom-Json + #scrivo il numero del progetto nel terminale e su file + WriteLogOutput 1 "" + WriteLogOutput 1 "--------------------" + WriteLogOutput 1 "**PROGETTO $projectCount**" + foreach($item in $parsedResponse) + { + #verifico se i pipeline trovati per il progetto corrente hanno status "success" + if($item.status.Equals("success")) + { + WriteLogOutput 2 "Pipeline: $($item.web_url) - Status: $($item.status)" + $pipelineSuccessCount=$pipelineSuccessCount+1 + } + #i pipeline che non hanno status "success" vengono loggati con relativo errore + else + { + WriteLogOutput 1 "Pipeline: $($item.web_url) - Status: $($item.status)" + $pipelineErrorsCount=$pipelineErrorsCount+1 + } + } + $projectsWithPipeline=$projectsWithPipeline+1 + } + #scrivo se trovo un errore (in particolare progetto non trovato o privo di pipeline) durante il try/catch (solo se loglevel è = 3) + catch + { + WriteLogOutput 3 "" + WriteLogOutput 3 "--------------------" + WriteLogOutput 3 "**PROGETTO $projectCount NON ESISTENTE O PRIVO DI PIPELINE**" + } + $projectCount=$projectCount+1 +} +#fine ciclo principale +while($projectCount -le $projectNumber) + +#somma di pipelineSuccess e pipelineErrors +$pipelineCount = $pipelineSuccessCount+$pipelineErrorsCount + +#percentuale di pipelineSuccess sul totale +$pipelineSuccessPercentage = [math]::Round(($pipelineSuccessCount/$pipelineCount)*100,1) + +#percentuale di pipelineErrors sul totale +$pipelineErrorsPercentage = [math]::Round(($pipelineErrorsCount/$pipelineCount)*100,1) + +# fermo stopwatch e calcolo durata script +$mainStopWatch.Stop() +$durataScript = $mainStopWatch.Elapsed.TotalSeconds + +#rilevo time per log fine analisi +$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +#invio a zabbix le metriche rilevate tramite zabbix_sender.exe +WriteLogOutput 0 "" +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ProjectsWithPipeline -o $projectsWithPipeline +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.TotalPipeline -o $pipelineCount +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.SuccessPipeline -o $pipelineSuccessCount +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ErrorsPipeline -o $pipelineErrorsCount +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.SuccessPipelinePercent -o $pipelineSuccessPercentage +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.ErrorsPipelinePercent -o $pipelineErrorsPercentage +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gitlab.CheckPipelineDuration -o $durataScript + +#scrivo a video le statistiche +WriteLogOutput 0 "" +WriteLogOutput 0 "PROGETTI CON PIPELINE ATTIVE: $projectsWithPipeline" +WriteLogOutput 0 "PIPELINE TROVATE: $pipelineCount" +WriteLogOutput 0 "PIPELINE RIUSCITE: $pipelineSuccessCount ($pipelineSuccessPercentage%)" +WriteLogOutput 0 "PIPELINE FALLITE: $pipelineErrorsCount ($pipelineErrorsPercentage%)" +WriteLogOutput 0 "" +WriteLogOutput 0 "Fine Esecuzione Script: $endTime" +WriteLogOutput 0 "" +WriteLogOutput 0 "Durata Esecuzione Script: $durataScript secondi" +WriteLogOutput 0 "" \ No newline at end of file diff --git a/CheckGitlabProtectedBranches.ps1 b/CheckGitlabProtectedBranches.ps1 new file mode 100644 index 0000000..54381b9 --- /dev/null +++ b/CheckGitlabProtectedBranches.ps1 @@ -0,0 +1,137 @@ +################START SCRIPT################ + +#rilevo time per log inizio analisi +$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +# avvio stopwatch +$mainStopWatch = [system.diagnostics.stopwatch]::StartNew() + +#contatore ciclo do while +$projectCount = 1 + +#numero massimo di progetti da analizzare +$projectNumber = 150 + +#conteggio progetti trovati +$existingProjects = 0 + +#conteggio progetti trovati +$protectedProjects = 0 + +#livello di log: 0=log sintetico, 1=log errori, 2=log full, 3=log ampolloso +$logLevel = 3 + +#output a terminale: 0=disattivo, 1=abilitato +$terminalOutput = 1 + +#abilita o disabilita la cancellazione della protezione (1=cancella, 0=toca negot) +$deleteProtection = 0 + +#specifica quale installazione di gitlab va controllata + +#$gitlabIstance = "https://gitlab-nembro" +#$head = @{"PRIVATE-TOKEN"="glpat-TzZkRUoYAdKikgwFXW_E"} +$gitlabIstance = "https://gitlab-azzano" +$head = @{"PRIVATE-TOKEN"="glpat-gADkrEhkEsvQxGxKez4y"} + +#cartella file di log +$GitLogFolder="c:\Steamware\Logs\Gitlab\" + +#nome file di log +$logFile = Join-Path $GitLogFolder "GitlabProtectedBranches.log" + +#dichiaro funzione per scrittura output +Function WriteLogOutput +{ + Param ($logType, [string]$logString) + if($logType -le $logLevel) + { + #scrivo su file la stringa + Add-content $logFile -value "$logString" + #scrivo su terminale la stringa se $terminalOutput=1 + if($terminalOutput -eq 1){ + Write-Output($logString) + } + } +} + +#creazione folder di Log se non già esistente +if (Test-Path $GitLogFolder) +{ +} +else +{ + New-Item $GitLogFolder -ItemType Directory +} + +#scrivo intestazione e inizio analisi +WriteLogOutput 0 "--------------------" +Switch ($logLevel) +{ + 0 {WriteLogOutput 0 "LOG SINTETICO GITLAB PROTECTED_BRANCHES"} + 1 {WriteLogOutput 0 "LOG ERRORI GITLAB PROTECTED_BRANCHES"} + 2 {WriteLogOutput 0 "LOG FULL GITLAB PROTECTED_BRANCHES"} + 3 {WriteLogOutput 0 "LOG AMPOLLOSO PROTECTED_BRANCHES"} +} +WriteLogOutput 0 "" +WriteLogOutput 0 "Percorso log: $GitLogFolder" +WriteLogOutput 0 "" +WriteLogOutput 0 "Inizio Esecuzione Script: $startTime" + +#ciclo principale do/while che cicla da 1 a N projectNumber +do +{ + #chiamata api che restituisce informazioni sullo stato dei mirror + $callUrl = $gitlabIstance + ".steamware.net/api/v4/projects/" + $projectCount + "/protected_branches" + try + { + #parsing della risposta api convertita da json + $Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing + $parsedResponse = $Response.Content | ConvertFrom-Json + #scrivo il numero del progetto nel terminale e su file + WriteLogOutput 1 "" + WriteLogOutput 1 "--------------------" + WriteLogOutput 1 "**PROGETTO $projectCount**" + foreach($item in $parsedResponse) + { + WriteLogOutput 1 "Protected Branch Name: $($item.name) - Allow Force Push: $($item.allow_force_push)" + $protectedProjects=$protectedProjects+1 + if($deleteProtection -eq 1) + { + #nuovo URL x delete + $callUrlDelete = $gitlabIstance + ".steamware.net/api/v4/projects/" + $projectCount + "/protected_branches/" + $item.name + #chiamo method DELETE + Invoke-WebRequest -Method Delete -URI $callUrlDelete -Headers $head -ContentType "application/json" -UseBasicParsing + } + } + $existingProjects=$existingProjects+1 + } + #scrivo se trovo un errore (in particolare progetto ID non trovato) durante il try/catch + catch + { + WriteLogOutput 3 "" + WriteLogOutput 3 "--------------------" + WriteLogOutput 3 "**ERRORE: PROGETTO $projectCount NON ESISTENTE**" + } + $projectCount=$projectCount+1 +} +#fine ciclo principale +while($projectCount -le $projectNumber) + +# fermo stopwatch e calcolo durata script +$mainStopWatch.Stop() +$durataScript = $mainStopWatch.Elapsed.TotalSeconds + +#rilevo time per log fine analisi +$endTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +#scrivo a video le statistiche +WriteLogOutput 0 "" +WriteLogOutput 0 "PROGETTI ANALIZZATI: $existingProjects" +WriteLogOutput 0 "" +WriteLogOutput 0 "PROGETTI CON BRANCH PROTETTI: $protectedProjects" +WriteLogOutput 0 "" +WriteLogOutput 0 "Fine Esecuzione Script: $endTime" +WriteLogOutput 0 "" +WriteLogOutput 0 "Durata Esecuzione Script: $durataScript secondi" +WriteLogOutput 0 "" \ No newline at end of file diff --git a/GPW_CheckProj_office.ps1 b/GPW_CheckProj_office.ps1 new file mode 100644 index 0000000..071508f --- /dev/null +++ b/GPW_CheckProj_office.ps1 @@ -0,0 +1,109 @@ +<# + +ESEGUE UNA CHIAMATA A UNA uri e fa il log dei dati restituiti ... + +Se tutto Ok scrive un file di check, questo file viene usato per verificare che non sia già stato eseguito in modo corretto nelle +precedenti n. ore, così posso schedularlo più volte + +Esegue prima una chiamata ping al server, poi una chiamata a una URL di test e infine la chiamata effettiva + +Sarebbe da sistemare e rendere parametrica / procedura ... + + +# *** NOTE TECNICHE PER SCHEDULAZIONE + +# Per far scrivere il ritorno dalla chiamata di IIS nel file di log ho creato la schedulazione entrando con +# l'utente stesso (Steamware) che esegue lo script e ho fatto import della schedulazione ( in ambiente ISE il log lo scrive ) +# Ho messo anche permessi all'utente "Logon as batch job" ( vedi sotto ) + +# Utente messo in PowerUser e permessi scrittura cartella Steamware + +# Logon as batch job policy is set for the user. This policy is accessible by opening the Control Panel, Administrative Tools, +# and then Local Security Policy -> Local Policy -> User Rights Assignment -> then Logon as batch job. + +# Task Security Context +# https://forsenergy.com/en-us/taskscheduler/html/a922c2b5-6a43-4503-ab7f-4f3d77b3cc8a.htm + +# Mod. 2022-05-16 Minor Fix +# Mod. 2022-05-17 Ping e Varie +# Mod. 2022-05-18 add Check ObjTest +# Mod. 2023.03.14 fix invoke webrequest con -UseBasicParsing +# Mod. 2023.07.26 fix salvataggio check obj odierno: solo in finally (altrimenti registrato anche con errore chiamata) + +#> + +Remove-Variable * -ErrorAction SilentlyContinue # pulisco variabili x ISE + +# avvio stopwatch +$stopwatch = [system.diagnostics.stopwatch]::StartNew() + +$FolderName="c:\Steamware\Logs" +$Logfile = Join-Path $FolderName "\GPW_checkProj.log" + +$Server = "office.egalware.com" +$testUri = "https://office.egalware.com/GPW/Api/api/VC19" +$callUri = "https://office.egalware.com/GPW/Api/api/ProjCheck/ResAlloc" + +# file scritto solo se tutto OK - check se scritto in precedenza non eseguo +$ObjTest = Join-Path $FolderName "\GPW_checkProjOk.log" +$CheckHour = -6 + +Function LogWrite +{ Param ([string]$logstring) + $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss.fff") + Add-content $Logfile -value "$Stamp $logstring" +} + +# test e creazione DIR di Log +if (Test-Path $FolderName) +{ + # Write-Host "Folder Exists" +} +else +{ #PowerShell Create directory if not exists + New-Item $FolderName -ItemType Directory + Write-Host "Folder Created successfully" +} + +# Test, se già eseguito in modo corretto in precedenza esco... ( file $ObjTest scritto nelle ore precedenti ) +#$time = (Get-Date).AddMinutes( -1 ) +$time = (Get-Date).AddHours( $CheckHour ) +if ( Get-ChildItem -Path $ObjTest -Recurse -Force | Where-Object {$_.LastWriteTime -gt $time } ) { + LogWrite("CheckProj process already done...") + Break +} +else { + LogWrite("Start CheckProj process...") + + try { + # prima faccio una chiamata di test per "svegliare" IIS... + LogWrite("Test Call") + Invoke-WebRequest -URI $testUri -UseBasicParsing + } + catch { + LogWrite("TEST Call Error...") + LogWrite($Error[0]) + } + + try { + # vera chiamata + LogWrite("Test Call effettuata, effettuo chiamata target") + $Response = Invoke-WebRequest -URI $callUri -UseBasicParsing + } + catch { + $Response = 'CALL ERROR ...' + LogWrite($Error[0]) + } + finally + { + LogWrite("*** END Call ***") + $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss.fff") + Add-content $ObjTest -value "$Stamp" + } + + # fermo stopwatch e conteggio... + $stopwatch.Stop() + $durata = $stopwatch.Elapsed.TotalSeconds + & "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gpw.Proj -o $durata + LogWrite("Durata esecuzione: $durata") +} diff --git a/GPW_CheckScadenzeLic.ps1 b/GPW_CheckScadenzeLic.ps1 new file mode 100644 index 0000000..33db487 --- /dev/null +++ b/GPW_CheckScadenzeLic.ps1 @@ -0,0 +1,69 @@ + + +# Per far scrivere il ritorno dalla chiamata di IIS nel file di log ho creato la schedulazione entrando con +# l'utente stesso (Steamware) che esegue lo script e ho fatto import della schedulazione ( in ambiente ISE il log lo scrive ) +# Ho messo anche permessi all'utente "Logon as batch job" ( vedi sotto ) + +# Utente messo in PowerUser e permessi scrittura cartella Steamware + +# Logon as batch job policy is set for the user. This policy is accessible by opening the Control Panel, Administrative Tools, +# and then Local Security Policy -> Local Policy -> User Rights Assignment -> then Logon as batch job. + +# Task Security Context +# https://forsenergy.com/en-us/taskscheduler/html/a922c2b5-6a43-4503-ab7f-4f3d77b3cc8a.htm + +# Mod. 2022-05-17 Inizio ... + +Remove-Variable * -ErrorAction SilentlyContinue # pulisco variabili x ISE + +# avvio stopwatch +$stopwatch = [system.diagnostics.stopwatch]::StartNew() + +$FolderName="c:\Steamware\Logs" +$Logfile = Join-Path $FolderName "\GPW_CheckScadenzeLic.log" +$Server = "liman.egalware.com" +$callUri = "https://liman.egalware.com/ELM.API/api/licenza/CheckScadenze" +$ErrorActionPreference = "Stop" + +Function LogWrite +{ + Param ([string]$logstring) + + $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss.fff") + Add-content $Logfile -value "$Stamp $logstring" +} + +if (Test-Path $FolderName) { + # Write-Host "Folder Exists" +} +else +{ #PowerShell Create directory if not exists + New-Item $FolderName -ItemType Directory + Write-Host "Folder Created successfully" +} + +LogWrite("Start Check Licenses process...") + +# # TEST CONNECTION +# LogWrite("Start Ping --> $Server ...") +# Test-Connection -ComputerName $Server -ErrorAction SilentlyContinue | Format-Table -AutoSize | Out-File -encoding utf8 $Logfile -Append # se non lo trova prosegue cmq + +try { # vera chiamata + LogWrite("Effettuo chiamata target...") + $Response = Invoke-WebRequest -URI $callUri -UseBasicParsing + LogWrite($Response) +} +catch { + $Response = 'Call ERROR ...' + LogWrite($Error[0]) +} +finally +{ + LogWrite("*** END Call ***") +} + +# fermo stopwatch e conteggio... +$stopwatch.Stop() +$durata = $stopwatch.Elapsed.TotalSeconds +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k LiMan.Lic -o $durata +LogWrite("Durata esecuzione: $durata") diff --git a/GPW_CheckTimb_office.ps1 b/GPW_CheckTimb_office.ps1 new file mode 100644 index 0000000..b1f7da9 --- /dev/null +++ b/GPW_CheckTimb_office.ps1 @@ -0,0 +1,108 @@ +<# + +ESEGUE UNA CHIAMATA A UNA uri e fa il log dei dati restituiti ... + +Se tutto Ok scrive un file di check, questo file viene usato per verificare che non sia già stato eseguito in modo corretto nelle +precedenti n. ore, così posso schedularlo più volte + +Esegue prima una chiamata ping al server, poi una chiamata a una URL di test e infine la chiamata effettiva + +Sarebbe da sistemare e rendere parametrica / procedura ... + + +# *** NOTE TECNICHE PER SCHEDULAZIONE + +# Per far scrivere il ritorno dalla chiamata di IIS nel file di log ho creato la schedulazione entrando con +# l'utente stesso (Steamware) che esegue lo script e ho fatto import della schedulazione ( in ambiente ISE il log lo scrive ) +# Ho messo anche permessi all'utente "Logon as batch job" ( vedi sotto ) + +# Utente messo in PowerUser e permessi scrittura cartella Steamware + +# Logon as batch job policy is set for the user. This policy is accessible by opening the Control Panel, Administrative Tools, +# and then Local Security Policy -> Local Policy -> User Rights Assignment -> then Logon as batch job. + +# Task Security Context +# https://forsenergy.com/en-us/taskscheduler/html/a922c2b5-6a43-4503-ab7f-4f3d77b3cc8a.htm + +# Mod. 2022-05-16 Minor Fix +# Mod. 2022-05-17 Ping e Varie +# Mod. 2022-05-18 add Check ObjTest + +#> + +Remove-Variable * -ErrorAction SilentlyContinue # pulisco variabili x ISE + +# avvio stopwatch +$stopwatch = [system.diagnostics.stopwatch]::StartNew() + +$FolderName="c:\Steamware\Logs" +$Logfile = Join-Path $FolderName "\GPW_checkTimb.log" + +$Server = "office.egalware.com" +$testUri = "https://office.egalware.com/GPW/Api/api/VC19" +$callUri = "https://office.egalware.com/GPW/Api/api/TimbraCheck/DailyCheck" + +# file scritto solo se tutto OK - check se scritto in precedenza non eseguo +$ObjTest = Join-Path $FolderName "\GPW_checkTimbOk.log" +$CheckHour = -6 + +Function LogWrite +{ Param ([string]$logstring) + + $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss.fff") + Add-content $Logfile -value "$Stamp $logstring" +} + +# test e creazione DIR di Log +if (Test-Path $FolderName) +{ + # Write-Host "Folder Exists" +} +else +{ #PowerShell Create directory if not exists + New-Item $FolderName -ItemType Directory + Write-Host "Folder Created successfully" +} + +# Test, se già eseguito in modo corretto in precedenza esco... ( file $ObjTest scritto nelle ore precedenti ) +$time = (Get-Date).AddHours( $CheckHour ) +if ( Get-ChildItem -Path $ObjTest -Recurse -Force | Where-Object {$_.LastWriteTime -gt $time } ) { + LogWrite("CheckProj process already done...") + Break +} +else { LogWrite("Start CheckProj process...") } + +# # TEST PING CONNECTION +# LogWrite("Start Ping --> $Server ...") +# Test-Connection -ComputerName $Server -ErrorAction SilentlyContinue | Format-Table -AutoSize | Out-File -encoding utf8 $Logfile -Append # se non lo trova prosegue cmq + +try { # prima faccio una chiamata di test per "svegliare" IIS... + LogWrite("Test Call") + Invoke-WebRequest -URI $testUri -UseBasicParsing +} +catch { + LogWrite("TEST Call Error...") + LogWrite($Error[0]) +} + +try { # vera chiamata + LogWrite("Test Call effettuata, effettuo chiamata target") + $Response = Invoke-WebRequest -URI $callUri -UseBasicParsing + LogWrite($Response) + (Get-Date).toString("yyyy/MM/dd HH:mm:ss.fff") | Out-File $ObjTest + #[string]$Return = $Response.Content # messo per prova visto che non creava nulla in LOG - potrebbe non servire +} +catch { + $Response = 'CALL ERROR ...' + LogWrite($Error[0]) +} +finally +{ + LogWrite("*** END Call ***") +} + +# fermo stopwatch e conteggio... +$stopwatch.Stop() +$durata = $stopwatch.Elapsed.TotalSeconds +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gpw.Timb -o $durata +LogWrite("Durata esecuzione: $durata") \ No newline at end of file diff --git a/GPW_StartApps_office.ps1 b/GPW_StartApps_office.ps1 new file mode 100644 index 0000000..3f3067e --- /dev/null +++ b/GPW_StartApps_office.ps1 @@ -0,0 +1,84 @@ +<# + +ESEGUE UNA CHIAMATA A UNA uri e fa il log dei dati restituiti ... + +Se tutto Ok scrive un file di check, questo file viene usato per verificare che non sia già stato eseguito in modo corretto nelle +precedenti n. ore, così posso schedularlo più volte + +Esegue prima una chiamata ping al server, poi una chiamata a una URL di test e infine la chiamata effettiva + +Sarebbe da sistemare e rendere parametrica / procedura ... + + +# *** NOTE TECNICHE PER SCHEDULAZIONE + +# Per far scrivere il ritorno dalla chiamata di IIS nel file di log ho creato la schedulazione entrando con +# l'utente stesso (Steamware) che esegue lo script e ho fatto import della schedulazione ( in ambiente ISE il log lo scrive ) +# Ho messo anche permessi all'utente "Logon as batch job" ( vedi sotto ) + +# Utente messo in PowerUser e permessi scrittura cartella Steamware + +# Logon as batch job policy is set for the user. This policy is accessible by opening the Control Panel, Administrative Tools, +# and then Local Security Policy -> Local Policy -> User Rights Assignment -> then Logon as batch job. + +# Task Security Context +# https://forsenergy.com/en-us/taskscheduler/html/a922c2b5-6a43-4503-ab7f-4f3d77b3cc8a.htm + +# Mod. 2022-05-16 Minor Fix +# Mod. 2022-05-17 Ping e Varie +# Mod. 2022-05-18 add Check ObjTest + +#> + +Remove-Variable * -ErrorAction SilentlyContinue # pulisco variabili x ISE + +# avvio stopwatch +$stopwatch = [system.diagnostics.stopwatch]::StartNew() + +$FolderName="c:\Steamware\Logs" +$Logfile = Join-Path $FolderName "\GPW_Core_Start.log" + +$Server = "office.egalware.com" +$testUri = "https://office.egalware.com/GPW/Api/api/VC19" +$callUri01 = "https://office.egalware.com/GPW/CORE.WRKLOG/" +$callUri02 = "https://office.egalware.com/GPW/CORE.SMART/" + +Function LogWrite +{ Param ([string]$logstring) + + $Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss.fff") + Add-content $Logfile -value "$Stamp $logstring" +} + +# test e creazione DIR di Log +if (Test-Path $FolderName) +{ + #Write-Host "Folder Exists" +} +else +{ #PowerShell Create directory if not exists + New-Item $FolderName -ItemType Directory + Write-Host "Folder Created successfully" +} + +try { # vera chiamata + LogWrite("Test Call effettuata, effettuo chiamata target") + $Response = Invoke-WebRequest -URI $callUri01 -UseBasicParsing + $Response = Invoke-WebRequest -URI $callUri02 -UseBasicParsing + LogWrite("Call effettuate!") + #[string]$Return = $Response.Content # messo per prova visto che non creava nulla in LOG - potrebbe non servire +} +catch { + $Response = 'CALL ERROR ...' + LogWrite($Error[0]) +} +finally +{ + LogWrite("*** END Call ***") +} + +# fermo stopwatch e conteggio... +$stopwatch.Stop() +$durata = $stopwatch.Elapsed.TotalSeconds +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabproxy.ufficio -s "IIS04" -k Gpw.Core -o $durata +LogWrite("Durata esecuzione: $durata") \ No newline at end of file diff --git a/TEST_SENDER.ps1 b/TEST_SENDER.ps1 new file mode 100644 index 0000000..8aab6a9 --- /dev/null +++ b/TEST_SENDER.ps1 @@ -0,0 +1,37 @@ +<# + +ESEGUE UNA CHIAMATA A UNA uri e fa il log dei dati restituiti ... + +Se tutto Ok scrive un file di check, questo file viene usato per verificare che non sia già stato eseguito in modo corretto nelle +precedenti n. ore, così posso schedularlo più volte + +Esegue prima una chiamata ping al server, poi una chiamata a una URL di test e infine la chiamata effettiva + +Sarebbe da sistemare e rendere parametrica / procedura ... + + +# *** NOTE TECNICHE PER SCHEDULAZIONE + +# Per far scrivere il ritorno dalla chiamata di IIS nel file di log ho creato la schedulazione entrando con +# l'utente stesso (Steamware) che esegue lo script e ho fatto import della schedulazione ( in ambiente ISE il log lo scrive ) +# Ho messo anche permessi all'utente "Logon as batch job" ( vedi sotto ) + +# Utente messo in PowerUser e permessi scrittura cartella Steamware + +# Logon as batch job policy is set for the user. This policy is accessible by opening the Control Panel, Administrative Tools, +# and then Local Security Policy -> Local Policy -> User Rights Assignment -> then Logon as batch job. + +# Task Security Context +# https://forsenergy.com/en-us/taskscheduler/html/a922c2b5-6a43-4503-ab7f-4f3d77b3cc8a.htm + +# Mod. 2022-05-16 Minor Fix +# Mod. 2022-05-17 Ping e Varie +# Mod. 2022-05-18 add Check ObjTest + +#> + +Remove-Variable * -ErrorAction SilentlyContinue # pulisco variabili x ISE + +$durata = 5 + +& "C:\Program Files\Zabbix Agent\zabbix_sender.exe" -z zabbix.ufficio -s "IIS04" -k TESTER -o $durata \ No newline at end of file diff --git a/TestCall.ps1 b/TestCall.ps1 new file mode 100644 index 0000000..0c3047d --- /dev/null +++ b/TestCall.ps1 @@ -0,0 +1,9 @@ + + + +$head = @{"PRIVATE-TOKEN"="glpat-dQsUhS-GxNomkh1GnjHZ"} +$projectCount=1 +#$callUrl = "https://gitlab.steamware.net/api/v4/projects/" + $projectCount + "/remote_mirrors" +$callUrl = "https://gitlab.steamware.net/" +$Response = Invoke-WebRequest -URI $callUrl -Headers $head -ContentType "application/json" -UseBasicParsing +Write-Output($Response) diff --git a/WDC_SyncWebCompo.ps1 b/WDC_SyncWebCompo.ps1 new file mode 100644 index 0000000..3affa6e --- /dev/null +++ b/WDC_SyncWebCompo.ps1 @@ -0,0 +1,78 @@ +#SCRIPT PER ROBOCOPIARE CARTELLA WEBDOOR + +####INIZIO DICHIARAZIONE VARIABILI#### + +#rilevo time per log inizio analisi +$startTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") + +# avvio stopwatch +$mainStopWatch = [system.diagnostics.stopwatch]::StartNew() + +#abilitazione log: 0=disattivo, 1=abilitato +$logEnable = 0 + +#cartella file di log +$WdcLogFolder="c:\Steamware\Logs\WDC\" + +#nome file di log +$logFile = Join-Path $WdcLogFolder "WDC_Log.log" + +#folder source per robocopy +$sourceFolder = "\\stor01\TEAM DRIVES\30_Clienti\ABH\DataImport\Compo" + +#folder destination per robocopy +$destFolder = "\\IIS04\WebDoorSync\NewComp\Compo" + +####FINE DICHIARAZIONE VARIABILI#### + +#dichiaro funzione per scrittura output +Function WriteLogOutput +{ + Param ([string]$logString) + #scrivo su file la stringa + Add-content $logFile -value "$logString" + #scrivo su terminale la stringa se $logEnable=1 + if($logEnable -eq 1){ + Write-Output($logString) + } +} + +#creazione folder di Log se non già esistente +if (Test-Path $WdcLogFolder) +{ +} +else +{ + New-Item $WdcLogFolder -ItemType Directory +} + +#effettuo robocopy +try +{ + WriteLogOutput "------WDC SYNC------" + if ($logEnable -eq 1) + { + robocopy $sourceFolder $destFolder /mir /log+:$logFile + } + else + { + WriteLogOutput "" + WriteLogOutput "Started: $startTime" + WriteLogOutput "Source: $sourceFolder" + WriteLogOutput "Destination: $destFolder" + robocopy $sourceFolder $destFolder /mir + } + WriteLogOutput "Robocopy OK" +} +catch +{ + WriteLogOutput "An error occurred" +} + +# fermo stopwatch e calcolo durata script +$mainStopWatch.Stop() +$durataScript = $mainStopWatch.Elapsed.TotalSeconds + +#scrivo le statistiche +WriteLogOutput "Duration: $durataScript seconds" +WriteLogOutput "" \ No newline at end of file diff --git a/syncFileUpload.bat b/syncFileUpload.bat new file mode 100644 index 0000000..fb4b444 --- /dev/null +++ b/syncFileUpload.bat @@ -0,0 +1,4 @@ +@ECHO off +REM Effettua chimata x sync fileUpload da IIS03 a stor01... + +ROBOCOPY C:\inetpub\liman.egalware.com\MP\fileUpload "\\stor01\TEAM DRIVES\40_FileUpload\ConfMan.IOB" /MIR