Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$RestartProgram = Get-CimInstance -ClassName "CCM_SoftwareDistribution" -Namespace "ROOT\ccm\policy\machine\actualconfig" | Where-Object {$_.PKG_Name -match "Restart Computer" -and $_.PRG_ProgramName -match "Exit Force Restart"}
$RestartProgramDeployID = $RestartProgram.ADV_AdvertisementID
$RestartProgramPackageID = $RestartProgram.PKG_PackageID
$RestartProgramProgramID = $RestartProgram.PRG_ProgramID
[XML]$XML = $RestartProgram.PRG_Requirements
$Schedule = $xml.SWDReserved.ScheduledMessageID
$Program = ([wmi]"ROOT\ccm\policy\machine\actualconfig:CCM_SoftwareDistribution.ADV_AdvertisementID='$($RestartProgramDeployID)',PKG_PackageID='$($RestartProgramPackageID)',PRG_ProgramID='$($RestartProgramProgramID)'")
$Program.ADV_RepeatRunBehavior = 'RerunAlways'
$Program.ADV_MandatoryAssignments = 'True'
$Program.put()
([wmiclass]'ROOT\ccm:SMS_Client').TriggerSchedule($Schedule)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.