fix(setup): $sdFiles.Count null-dereference under StrictMode — wrap in @()
$sdFiles is $null when SoftwareDistribution\Download is empty. StrictMode throws on $null.Count. @($sdFiles).Count safely returns 0 for null. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1036,7 +1036,7 @@ $sdFiles = Get-ChildItem 'C:\Windows\SoftwareDistribution\Download' -Recurse -Fi
|
|||||||
$sdBytes = [long]0
|
$sdBytes = [long]0
|
||||||
if ($sdFiles) { foreach ($f in $sdFiles) { $sdBytes += $f.Length } }
|
if ($sdFiles) { foreach ($f in $sdFiles) { $sdBytes += $f.Length } }
|
||||||
$sdMB = [math]::Round($sdBytes / 1MB, 1)
|
$sdMB = [math]::Round($sdBytes / 1MB, 1)
|
||||||
Write-Host " SoftwareDistribution\Download: $($sdFiles.Count) file(s), ${sdMB} MB remaining (WaaSMedicSvc best-effort, WU is disabled)."
|
Write-Host " SoftwareDistribution\Download: $(@($sdFiles).Count) file(s), ${sdMB} MB remaining (WaaSMedicSvc best-effort, WU is disabled)."
|
||||||
|
|
||||||
Assert-Step 'Cleanup' 'wuauserv StartType Disabled after cache clear' {
|
Assert-Step 'Cleanup' 'wuauserv StartType Disabled after cache clear' {
|
||||||
(Get-Service wuauserv -ErrorAction Stop).StartType -eq 'Disabled'
|
(Get-Service wuauserv -ErrorAction Stop).StartType -eq 'Disabled'
|
||||||
|
|||||||
Reference in New Issue
Block a user