Created
May 24, 2019 12:46
-
-
Save CodyMathis123/a1a7ae087852c48ac7e3d1131e2c1424 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
$TimeFrame = (Get-Date).AddMinutes(-17) | |
$Filter = @{ | |
LogName = 'System' | |
StartTime = $TimeFrame | |
Id = '19' | |
ProviderName = 'Microsoft-Windows-WindowsUpdateClient' | |
} | |
$Events = Get-WinEvent -FilterHashtable $Filter | |
foreach ($Event in $Events) { | |
switch -Regex ($Event.Message) { | |
'Servicing Stack Update' { | |
foreach ($Schedule in @('108', '113')) { | |
$ScheduleString = [string]::Format('{{00000000-0000-0000-0000-000000000{0}}}', $Schedule) | |
$invokeWmiMethodSplat = @{ | |
Name = 'TriggerSchedule' | |
Namespace = 'root\ccm' | |
Class = 'sms_client' | |
ArgumentList = $ScheduleString | |
ErrorAction = 'Stop' | |
} | |
Invoke-WmiMethod @invokeWmiMethodSplat | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment