Nuovo Script - Check W32Time Difference
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
####SCRIPT PER CONTROLLARE TIME DRIFT WINDOWS####
|
||||
|
||||
#rilevo data e ora
|
||||
$currentTime = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
|
||||
#nome file di log
|
||||
$logFile = "W32TimeDriftCheck.log"
|
||||
#cartella file di log
|
||||
$logFolder = "c:\Steamware\Logs\"
|
||||
#opzione log su file: scrivo se = 1, ignoro se = 0
|
||||
$logType = 1
|
||||
#opzione output in terminale: scrivo se = 1, ignoro se = 0
|
||||
$terminalOutput = 1
|
||||
#Ipv4 PDC
|
||||
$PDC = "10.74.82.251"
|
||||
#Ipv4 BDC
|
||||
$BDC = "10.74.82.250"
|
||||
|
||||
#creazione folder di Log se non già esistente
|
||||
if (Test-Path $logFolder) {
|
||||
}
|
||||
else {
|
||||
New-Item $logFolder -ItemType Directory
|
||||
}
|
||||
|
||||
#funzione locale per log su file e output su terminale
|
||||
Function WriteLogOutput {
|
||||
Param ([string]$logString)
|
||||
#compongo path per file di log
|
||||
$logPath = Join-Path $logFolder $logFile
|
||||
#scrivo su file la stringa se $logType=1
|
||||
if ($logType -eq 1) {
|
||||
Add-content $logPath -value "$logString"
|
||||
}
|
||||
#scrivo su terminale la stringa se $terminalOutput=1
|
||||
if ($terminalOutput -eq 1) {
|
||||
Write-Output($logString)
|
||||
}
|
||||
}
|
||||
|
||||
#calcolo differenza PDC, restituisco in secondi
|
||||
$timeDifferencePDC = (& w32tm /stripchart /computer:$PDC /samples:1 /dataonly)[-1].Trim("s") -split ',\s*'
|
||||
#calcolo differenza BDC, restituisco in secondi
|
||||
$timeDifferenceBDC = (& w32tm /stripchart /computer:$BDC /samples:1 /dataonly)[-1].Trim("s") -split ',\s*'
|
||||
|
||||
#scrivo log data e ora
|
||||
WriteLogOutput "Script Execution: $currentTime"
|
||||
#output differenza PDC
|
||||
WriteLogOutput "Time Difference W2022PDC: $timeDifferencePDC s"
|
||||
#output differenza BDC
|
||||
WriteLogOutput "Time Difference W2022BDC: $timeDifferenceBDC s"
|
||||
WriteLogOutput "---"
|
||||
Reference in New Issue
Block a user