diff --git a/scripts/diagnostics/Capture-MclCache.ps1 b/scripts/diagnostics/Capture-MclCache.ps1 index 4f8ff33..5ed38f7 100644 --- a/scripts/diagnostics/Capture-MclCache.ps1 +++ b/scripts/diagnostics/Capture-MclCache.ps1 @@ -189,8 +189,8 @@ Write-Host "Copying to $target ..." & robocopy.exe $dest $target /E /COPY:DT /R:2 /W:5 /NP /NFL /NDL /NJH /NJS | Out-Null $rc = $LASTEXITCODE if ($rc -ge 8) { - Write-Host "Copy FAILED (robocopy exit $rc)." -ForegroundColor Red - exit 2 + # Keep going: the check below names the files that did not arrive. + Write-Host "robocopy could not copy some files (exit $rc)." -ForegroundColor Yellow } # Read every file back through the share and compare with SHA256SUMS. @@ -200,16 +200,20 @@ foreach ($line in $sumLines) { $rel = $line.Substring(66) $copy = Join-Path $target ($rel.Replace('/', '\')) if (-not (Test-Path -LiteralPath $copy -PathType Leaf)) { $bad.Add("missing $rel"); continue } - $got = (Get-FileHash -LiteralPath $copy -Algorithm SHA256).Hash.ToLower() + try { $got = (Get-FileHash -LiteralPath $copy -Algorithm SHA256).Hash.ToLower() } + catch { $bad.Add("unreadable $rel"); continue } if ($got -ne $hash) { $bad.Add("differs $rel ($((Get-Item -LiteralPath $copy).Length) bytes)") } } -if ((Get-FileHash -LiteralPath (Join-Path $target "SHA256SUMS") -Algorithm SHA256).Hash -ne - (Get-FileHash -LiteralPath (Join-Path $dest "SHA256SUMS") -Algorithm SHA256).Hash) { - $bad.Add("differs SHA256SUMS") -} +try { + if ((Get-FileHash -LiteralPath (Join-Path $target "SHA256SUMS") -Algorithm SHA256).Hash -ne + (Get-FileHash -LiteralPath (Join-Path $dest "SHA256SUMS") -Algorithm SHA256).Hash) { + $bad.Add("differs SHA256SUMS") + } +} catch { $bad.Add("unreadable SHA256SUMS") } if ($bad.Count) { Write-Host "Copy NOT verified: $($bad.Count) of $($sumLines.Count + 1) files wrong." -ForegroundColor Red foreach ($b in $bad) { Write-Host " $b" } + Write-Host "A file that arrives with 0 bytes was most likely blocked by this PC's policy." exit 2 } Write-Host "Copied and verified: all $($sumLines.Count + 1) files match." -ForegroundColor Green