Skip to content

Commit 990878f

Browse files
committed
Updated Invoke-CMSnowflakePatching
1 parent bf7e667 commit 990878f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
8-
7+
## [Unreleased]
8+
### Fixed
9+
- If an update returned a pending reboot, and the system rebooted, the output object would suggest a pending reboot is still required despite the update being successfully installed
10+
- Removed null values in error records causing non-terminators when trying to throw a terminating error with said error record, lol.
11+
912
## [0.2.1] - 2022-09-20
1013
### Fixed
1114
- `Invoke-CMSnowflakePatching` had incorrect logic to determine if target host had finished rebooting

src/Public/Invoke-CMSnowflakePatching.ps1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function Invoke-CMSnowflakePatching {
196196
$Exception = [System.ArgumentException]::new('Did not find a device collection with ID {0}' -f $CollectionId)
197197
$ErrorRecord = [System.Management.Automation.ErrorRecord]::new(
198198
$Exception,
199-
$null,
199+
0,
200200
[System.Management.Automation.ErrorCategory]::ObjectNotFound,
201201
$ComputerName
202202
)
@@ -315,8 +315,6 @@ function Invoke-CMSnowflakePatching {
315315
# Wait for SMS Agent Host to startup and for relevant ConfigMgr WMI classes to become available
316316
} -ExitCondition {
317317
try {
318-
#$null = Get-CMSoftwareUpdates -ComputerName $ComputerName -ErrorAction 'Stop'
319-
#return $true
320318
$Splat = @{
321319
ComputerName = $ComputerName
322320
ClassName = 'Win32_Service'
@@ -339,7 +337,7 @@ function Invoke-CMSnowflakePatching {
339337
$Exception = [System.TimeoutException]::new('Timeout while waiting for {0} to reboot' -f $ComputerName)
340338
$ErrorRecord = [System.Management.Automation.ErrorRecord]::new(
341339
$Exception,
342-
$null,
340+
0,
343341
[System.Management.Automation.ErrorCategory]::OperationTimeout,
344342
$ComputerName
345343
)
@@ -348,9 +346,8 @@ function Invoke-CMSnowflakePatching {
348346

349347
}
350348
} -ExitCondition {
351-
if ($Result.EvaluationState -notmatch '^8$|^9$|^13$') {
352-
# Don't bother doing ScanByUpdateSource if all the updates are in failed or pending reboot state
353-
# The point of this is to get updates out of WMI if they're successful/complete w/o pending reboot
349+
if ($Result.EvaluationState -notmatch '^13$') {
350+
# Don't bother doing ScanByUpdateSource if all the updates are in a failed state
354351
& $Module NewLoopAction -LoopTimeout $SoftwareUpdateScanCycleTimeoutMins -LoopTimeoutType 'Minutes' -LoopDelay 1 -LoopDelayType 'Seconds' -ScriptBlock { } -ExitCondition {
355352
try {
356353
Start-CMClientAction -ComputerName $ComputerName -ScheduleId 'ScanByUpdateSource' -ErrorAction 'Stop'
@@ -372,7 +369,7 @@ function Invoke-CMSnowflakePatching {
372369
$Exception = [System.TimeoutException]::new('Timeout while trying to invoke Software Update Scan Cycle for {0}' -f $ComputerName)
373370
$ErrorRecord = [System.Management.Automation.ErrorRecord]::new(
374371
$Exception,
375-
$null,
372+
0,
376373
[System.Management.Automation.ErrorCategory]::OperationTimeout,
377374
$ComputerName
378375
)

0 commit comments

Comments
 (0)