Preview scope, validate paths, log outcomes, and stop on critical failures.
Sheet: 25 of 25 | Platform: Windows 10/11 | Shell: PowerShell 7.x and Windows PowerShell 5.1 (unless marked otherwise) | Editorial review: November 24, 2026
Examples use the MGU project root and illustrative staging, backup, and download paths. Replace them with existing, approved paths as needed. Unless explicitly marked as a continuation, examples are independent. Read commands before running them; commands that write or modify files can change existing data.
Quick commands
1. Validate the intended root before any operation
$root = 'C:\MGU-Staging'
if (-not (Test-Path -LiteralPath $root -PathType Container)) { throw 'Expected root does not exist.' }
2. Materialize the target list and inspect it
$targets = @(Get-ChildItem -LiteralPath 'C:\MGU-Staging' -Recurse -File -Filter '*.tmp' -ErrorAction Stop)
$targets | Select-Object FullName, Length
'Target count: ' + $targets.Count
3. Preview changes (run after target list)
$targets | Remove-Item -WhatIf
4. Stop on a failed copy
try {
Copy-Item -LiteralPath 'C:\MGU-Staging\article.html' -Destination 'C:\MGU-Backup\article.html' -ErrorAction Stop
} catch { throw "Copy failed: $($_.Exception.Message)" }
5. Record a read-only preflight manifest (run after target list)
$targets | Select-Object FullName, Length, LastWriteTimeUtc |
Export-Csv -LiteralPath 'C:\MGU-Backup\preflight.csv' -NoTypeInformation -Encoding UTF8
6. Capture a scoped transcript of a read-only inspection
Start-Transcript -Path 'C:\MGU-Backup\inspection.log' -NoClobber
try { Get-ChildItem -LiteralPath 'C:\MGU-Staging' -File -ErrorAction Stop }
finally { Stop-Transcript }
Operational notes
WhatIf is supported by many modifying cmdlets, not by every command, .NET method or external program. A preview is not a transaction. Review targets, collisions, backups and permission errors; execute only an approved scope, then verify results. Transcripts may include sensitive paths and output.