powershell同步时间

第一步,判断Windows Time服务是否正在运行,如果没有,则开启它。

第二步,强制同步,不知为何,往往第一次会失败,那么就多运行几次好了。


Get-Service w32time | Where {$_.status –eq 'Stopped'} |  Start-Service

W32tm /resync /force

W32tm /resync /force

 

ps: powershell 部分需set-executionpolicy remotesigned将策略设置为RemoteSigned 否则可能脚本运行被禁止。

posted @ 2022-12-07 10:33  知鹿  阅读(103)  评论(0编辑  收藏  举报