Created
May 29, 2020 14:24
-
-
Save gwblok/ad56603bef9a6845e4401c40187cc941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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