用 PS 调整服务器时间
Powershell 有一个命令用来调整计算机的时间, Set-Date -Adjust,但是,只能调整本地时间,不能调整远程的计算机时间。
function AdjustDCTime ( $Server, $addTime ){
$Svr = Get-WmiObject Win32_OperatingSystem -ComputerName $Server
$time = $Svr.LocalDateTime
$NewTime = ( [wmi]"" ).ConvertToDateTime( $time ).AddSeconds( $addtime )
# $NewTime
$setTime = ( [wmi]"" ).ConvertFromDateTime( $NewTime )
$Svr.SetDateTime( $setTime )
# $time = $Svr.LocalDateTime
# $time
}
# $Server = "."
# $addTime = -60
AdjustDCTime "." 60