通过PowerShell触发SCCM强制重启倒计时后无法重启的问题
解决SCCM强制重启倒计时到0后不执行重启的问题
问题分析
核心问题在于RebootBy时间戳配置错误(设置为当前时间而非60分钟后),且未清理旧的RebootData注册表残留,导致倒计时结束后SCCM客户端无法触发重启动作。
修正后的脚本
# 设置重启倒计时时长(分钟) $rebootInMinutes = 60 # 计算60分钟后的UTC时间戳(配合RebootValueInUTC=1使用) $rebootByTime = (Get-Date).AddMinutes($rebootInMinutes) $rebootByTimestamp = [DateTimeOffset]::new($rebootByTime.ToUniversalTime()).ToUnixTimeSeconds() # 清除旧的RebootData配置,避免残留干扰 Remove-Item -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Recurse -Force -ErrorAction SilentlyContinue # 创建新的RebootData注册表项 New-Item -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Force -ErrorAction SilentlyContinue | Out-Null # 设置强制重启关键参数 New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'RebootBy' -Value $rebootByTimestamp -PropertyType QWord -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'RebootValueInUTC' -Value 1 -PropertyType DWord -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'NotifyUI' -Value 1 -PropertyType DWord -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'HardReboot' -Value 0 -PropertyType DWord -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'OverrideRebootWindowTime' -Value 0 -PropertyType QWord -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'OverrideRebootWindow' -Value 0 -PropertyType DWord -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'PreferredRebootWindowTypes' -Value @("4") -PropertyType MultiString -Force New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'GraceSeconds' -Value 0 -PropertyType DWord -Force # 触发SCCM重启通知并刷新客户端服务 Start-Process -FilePath "C:\Windows\CCM\CcmRestart.exe" -PassThru -WindowStyle Hidden Restart-Service -Name CcmExec -Force -ErrorAction SilentlyContinue
关键修改说明
- RebootBy时间戳:明确设置为60分钟后的UTC时间戳,确保倒计时从60分钟开始递减,而非直接显示0。
- 清理旧注册表项:删除之前的RebootData键,避免旧参数(如错误的RebootBy值)干扰新配置。
- GraceSeconds=0:无额外宽限期,倒计时结束后立即执行强制重启。
- 重启CCMExec服务:强制SCCM客户端加载新的重启配置,避免缓存旧设置导致不生效。
验证步骤
- 通过SCCM Client Center远程执行上述脚本。
- 确认目标设备弹出60分钟强制重启倒计时窗口。
- 等待倒计时结束,检查设备是否自动重启。
- 若仍失败,查看SCCM客户端日志
C:\Windows\CCM\Logs\RebootManagement.log,排查重启触发的错误信息。
内容的提问来源于stack exchange,提问作者Random206
相关产品推荐
相关产品推荐

