Random206
Random206

Reputation: 826

Using SCCM to force a reboot via powershell doesn't show the countdown

I'm trying to trigger the SCCM reboot countdown timer on a Windows machine using PowerShell. The countdown window appears as expected, but when the timer reaches 0, the system does not reboot. Instead, the UI just remains on the screen with the countdown stuck at 0, and the reboot never occurs.

Ultimately I want to trigger this PowerShell script on a remote device, using SCCM Client Center for Configuration Manager, and the script will trigger SCCM to launch the enforced reboot countdown timer for 60 minutes, then reboot the computer at the end of it. I am aware there are other tools that can do this, but I am trying to use the tools available to me, and that the end user is used to seeing.

I found a script located here but it doesn't seem to work as expected: https://sccmf12twice.com/sccm-reboot-decoded-how-to-make-a-pc-cancel-start-extend-or-change-mandatory-reboot-to-non-mandatory-on-the-fly/

What I Expected to Happen:

The SCCM reboot countdown timer should appear. (It does when RebootValueInUTC is set to 0) Once the timer reaches 0, the computer should force a reboot. (It doesn't.)

What I have tried

I have tried setting the RebootValueInUTC registry key property value to 0 (this prompts the countdown to appear), if I leave it as 1 as other sources say to do, it doesn't show the countdown, but does show the non-enforced notification that a user can simply click X on and close.

I have tried setting the $time variable to UTCNow instead of just Now, this doesn't seem to make a difference.

I have tried altering the GraceSeconds from 0 to 60, this will change the countdown time, but other than that doesn't do anything else.

Please note that I am replacing the last line of the script from the blog by simply running CCMRestart.exe which just restarts CCMExec.exe, I tried using the Restart-Service ccmexec -force and it does the same thing in terms of results.

The script I am referring to above is here:

$time = [DateTimeOffset]::Now.ToUnixTimeSeconds()
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'RebootBy' -Value $time -PropertyType QWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'RebootValueInUTC' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'NotifyUI' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'HardReboot' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'OverrideRebootWindowTime' -Value 0 -PropertyType QWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'OverrideRebootWindow' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'PreferredRebootWindowTypes' -Value @("4") -PropertyType MultiString -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -Name 'GraceSeconds' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
Start-Process -FilePath "C:\Windows\CCM\CcmRestart.exe" -PassThru -WindowStyle Hidden

Setting GraceSeconds to 60 and RebootValueInUTC to 0 will show this when the countdown reaches 0, and will not start the reboot. Image of an enforced reboot countdown from SCCM that has reached 0

Setting GraceSeconds to 60 and RebootValueInUTC to 1 will show the first image and when clicked on will show the second image, but no countdown.

Image 1:

Image of toast notification advising the user that their device needs to be rebooted

Image 2:

Image of a window advising the user they can choose to reboot now or be reminded at a later time with a drop down allowing the user to choose a timeframe to be reminded in 1 hour is listed in the drop down

I want the countdown option but with an enforced reboot when it reaches 0.

Upvotes: 1

Views: 60

Answers (0)

Related Questions