用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