Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodyMathis123/a1a7ae087852c48ac7e3d1131e2c1424 to your computer and use it in GitHub Desktop.
Save CodyMathis123/a1a7ae087852c48ac7e3d1131e2c1424 to your computer and use it in GitHub Desktop.
$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