Thursday, July 1, 2010

SCCM Create a collection of computers that need a restart after patches

Sometimes after you patch the machine should restart during it's maintanence window.  There are always times with the client it told to restart but it never does.
This will create a collection of such computers.  From here I normally set an advertisment to run the "shutdown -r -f -c Patch restart -t 300"
This way the computer restarts during the normal MW.

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,
from SMS_R_System
inner join SMS_G_System_PatchStatusEx on SMS_G_System_PatchStatusEx.ResourceID = SMS_R_System.ResourceId where SMS_G_System_PatchStatusEx.LastStateName = "reboot pending"