Compare-File

Compare-File is a PowerShell script that compares the contents of two (sets of) files and reports if they differ. It's roughly equivalent to diff -qr on Unix/Linux, but implemented entirely in PowerShell. It ignores metadata (date, time, etc.) and does not report specifics of the differences.

The built-in Compare-Object command can perform a similar function (and many others), but also has some limitations. Notably, it requires the entire file be loaded into memory (with Get-Content) to create a PowerShell object. Compare-File instead uses stream I/O to compare files in small pieces. This uses much less memory. (If you're comparing a multi-gigabyte disk image, that matters even today.)

Compare-File also uses memcmp from the Microsoft Visual C Runtime Library, which is very fast at a simple yes/no compare. In my brief testing, this was orders of magnitude faster than Compare-Object.

Download: Compare-File.ps1