Commands / Text and objects

Compare-Object

Compare two lists

intermediate Text and objects Aliases comparediff

Compare-Object
 Compare-Object -ReferenceObject $old -DifferenceObject $new
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Compare-Object

Compares two collections. <= means only in the reference (old). => means only in the difference (new). == appears if you pass -IncludeEqual.

Try this

$old = Get-Content -Path .\old.txt
$new = Get-Content -Path .\new.txt
Compare-Object -ReferenceObject $old -DifferenceObject $new

Coming from another shell

ShellWhat you might type
bash / zshdiff a.txt b.txt
cmd.exefc a.txt b.txt

More in From bash and From cmd.

Related commands