Compare file lists, text, metadata, and byte-level content between snapshots.
Sheet: 18 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. Compare two text files line by line
$a = @(Get-Content -LiteralPath 'C:\MGU-Staging\old.txt' -Encoding UTF8)
$b = @(Get-Content -LiteralPath 'C:\MGU-Staging\new.txt' -Encoding UTF8)
Compare-Object -ReferenceObject $a -DifferenceObject $b
2. Compare two file hashes
(Get-FileHash -LiteralPath 'C:\MGU-Staging\old.txt' -Algorithm SHA256).Hash -eq
(Get-FileHash -LiteralPath 'C:\MGU-Staging\new.txt' -Algorithm SHA256).Hash
3. Compare root-relative paths in two trees
$a = 'C:\MGU-Backup'; $b = 'C:\MGU-Staging'
$left = @(Get-ChildItem -LiteralPath $a -Recurse -File | ForEach-Object { $_.FullName.Substring($a.Length + 1) })
$right = @(Get-ChildItem -LiteralPath $b -Recurse -File | ForEach-Object { $_.FullName.Substring($b.Length + 1) })
Compare-Object -ReferenceObject $left -DifferenceObject $right
4. Compare one named file's metadata
Get-Item -LiteralPath 'C:\MGU-Backup\index.html','C:\MGU-Staging\index.html' |
Select-Object FullName, Length, LastWriteTimeUtc
5. Compare saved inventory records by path and length
$a = @(Import-Csv -LiteralPath 'C:\MGU-Staging\before.csv')
$b = @(Import-Csv -LiteralPath 'C:\MGU-Staging\after.csv')
Compare-Object -ReferenceObject $a -DifferenceObject $b -Property FullName, Length
Operational notes
In Compare-Object output, <= means reference-only and => means difference-only. Line comparison is not a full positional diff; use a dedicated diff tool for ordered edits. Equal length or timestamps do not establish identical contents; use hashes.