SCCM Reboot DECODED:: How to make a PC Cancel, Start, Extend or Change mandatory reboot to non-mandatory on the fly.

, , , , , , , , ,

How to make a PC Cancel, Start, Extend or Change mandatory reboot to non-mandatory on the fly.

In the past to stop a PC from rebooting when you didn’t want it to people would stop the ccmexec service and do a shutdown /a

But here is the problem with that..

  1.  Shutdown /a will normally tell you that no shutdown is pending.
  2.  Any number of things can restart ccmexec.

First, how to check if a reboot is pending VS a reboot is GOING to happen

On a win10 PC or has powershell 5 installed, use this

#Detect pending reboot:
Invoke-CimMethod -Namespace root/ccm/ClientSDK -ClassName CCM_ClientUtilities -MethodName DetermineIfRebootPending

On a win7 or old powershell 2 you need to use these.

#
([wmiclass]'ROOTccmClientSDK:CCM_ClientUtilities').DetermineIfRebootPending().RebootPending
([wmiclass]'ROOTccmClientSDK:CCM_ClientUtilities').DetermineIfRebootPending().IsHardRebootPending
([wmiclass]'ROOTccmClientSDK:CCM_ClientUtilities').DetermineIfRebootPending().RebootDeadline
([wmiclass]'ROOTccmClientSDK:CCM_ClientUtilities').DetermineIfRebootPending().NotifyUI

It will spit out something like this..

#PC with no pending reboot.

DisableHideTime     : 12/31/1969 2:00:00 PM
InGracePeriod       : False
IsHardRebootPending : False
NotifyUI            : False
RebootDeadline      : 12/31/1969 2:00:00 PM
RebootPending       : False
ReturnValue         : 0
PSComputerName      :

#PC with pending NON-mandatory reboot.

DisableHideTime : 12/31/1969 12:00:00 PM
InGracePeriod : False
IsHardRebootPending : False
NotifyUI : True
RebootDeadline : 12/31/1969 12:00:00 PM
RebootPending : True
ReturnValue : 0
PSComputerName :

#PC with pending mandatory reboot, notice the time stamp.

DisableHideTime : 5/1/2019 3:28:56 PM
InGracePeriod : True
IsHardRebootPending : False
NotifyUI : True
RebootDeadline : 5/1/2019 11:28:56 PM
RebootPending : True
ReturnValue : 0
PSComputerName :

 

Now for the magic…..

Everything that SCCM uses for knowing when and if it should reboot comes from here.

HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData

On a PC with no reboot pending, this key is empty.

So starting with that, this is how we can CANCEL a pending reboot.

#CANCEL a pending reboot
Remove-Item -path 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData';
Remove-Item -path 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Updates Management\Handler\UpdatesRebootStatus\*';
Remove-ItemProperty -name * -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired';

#on PS2.0, "Remove-ItemProperty" doesn't work, so use this.
#Remove-Item -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired';

shutdown -a 
Restart-Service ccmexec -force

But what if you just want to cancel the mandatory reboot and change it to a non-mandatory reboot so the user will still get the popup telling them they “need to” reboot?

#change mandatory reboot to  non-mandatory reboot
Set-Itemproperty -path 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -name 'RebootBy' -value 0;
Restart-Service ccmexec -force

What if we just want to extend the time of a mandatory reboot?

Example: In your client settings you have your reboot countdown set to 10 hours…. A user calls and says it’s going to reboot in 10 min and needs it extended… This will reset that users countdown timer back to 10 hours.

#Reset SCCM reboot countdown timer.
$time = [DateTimeOffset]::Now.ToUnixTimeSeconds()
Set-Itemproperty -path 'HKLM:\SOFTWARE\Microsoft\SMS\Mobile Client\Reboot Management\RebootData' -name 'RebootBy' -value $time;
Restart-Service ccmexec -force

What if you want to kick off the built in SCCM reboot WITH the client settings countdown timer?
NOTE: Setting $Time to 0 will popup the non-mandatory reboot window.

$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;

 

NOTE:: In all my tests after you run The powerShell command it takes about 30 seconds for the client to respond since after you restart the service it has to do all it’s internal checks to figure out what’s new.

#WeaponizedAutismFTW

Adjusting the ConfigMgr Script Execution Timeout (pre 1810)

, , , , ,

In ConfigMgr, scripts that execute default to having an execution timeout of 60 seconds.  Normally this timeout is fine but you may run into situations where scripts run long and clients start receiving the following error in DcmWmiProvider.log.

In-line script execution time-out…
Failed to process CScriptProvider::PutInstanceAsync.
The script execution has timed out. (Error: 87D00321; Source: CCM)

ConfigMgr 1810 introduced the option to set the script timeout, if you are not up to 1810 yet and need to adjust the timeout then you are in the right place.  User raphael at thedesktopteam.com posted a blog on how to adjust the timeout, this is a good script for a single site infrastructure but the client setting does not flow down from a CAS to primary sites.  For this reason I adapted his original script to handle a multi-level site hierarchy.  Update the variables at the top of the script as required and run it to set the script execution timeout.

$SiteCode = "CM1"
$SiteServer = "CM1.contoso.com"
$ScriptTimeout = 120

$CCMAgents = (gwmi -Namespace root\sms\site_$SiteCode -Class SMS_SCI_ClientComp -ComputerName $SiteServer | where {$_.ClientComponentName -eq 'Configuration Management Agent'})

foreach ($CCMAgent in $CCMAgents)
{
    $props = $CCMAgent.Props
 
    for ($i = 0; $i -lt $props.count; $i++)
    {
        if ($props[$i].PropertyName -eq "ScriptExecutionTimeout")
        {
            $props[$i].Value = $ScriptTimeout
            break
        }
    }
 
    $CCMAgent.Props = $Props
    $CCMAgent.Put()
}

ALSO CHECK : Co-management - Multiple Pilot Policies

SSRS Client Installation Troubleshooting

, , , , , , ,

Client Installation Troubleshooting

This will be the first part of many in a series of reports that I will offer for free to the community. The reports will cover wide range of items from OS Migration dashboards, Bit locker reports, SCCM Infrastructure health, Client health, Collection evaluation, etc. In each report I intent on there to be plenty of visuals to provide the tech a clean overview of what is happening in the environment. There will also be several troubleshooting notes included in this report to be a 1 stop shop for troubleshooting tool. Some reports during this series will have troubleshooting guides available as well. So far I am intending to release Client Installation Troubleshooting guides for OSD, client install, and software updates as I have already written several of them for previous customers.

The first report to be released will have a focus on identifying problems with client installation and providing some good.  This will eventually grow into a “Client Health Assessment” where there will be multiple reports all focused on client install/health/active etc.

Below we are able to get an overview of the client install failures within the last 30 days, and keep an eye on how many clients we currently have in the environment.

Client Installation Troubleshooting

I’m leveraging several CASE WHEN statements to translate the error codes to something the tech can easily troubleshoot.

Client Installation Troubleshooting

Please not that if your total systems number is off from what you see in your SCCM Console then look into your maintenance tasks/discovery items. It is not uncommon for me to see customers environments that do not have AD cleaned up…so long story short make sure your AD environment is cleaned up too.

Future Revision of this report will be released as part of client health Dashboard, with a few other reports.

Link to Report:
https://gallery.technet.microsoft.com/SSRS-SCCM-Client-Install-3bd9e6e6