I need to do a file comparison and want to use Powershell. I need an output file listing all of the differences. The below is a good start, but I need the file to inlcude line numbers, and the resulting Input Object currently also gets cut off after 89 characters - I need the full line to display:
compare-object (get-content $File1) (get-content $File2) | Out-File $Location
Compare-Object command in PowerShell is used to compare two objects. Objects can be a variable content, two files, strings, etc. This cmdlet uses few syntaxes to show the difference between objects which is called side indicators. => - Difference in destination object.
The Compare-Object cmdlet compares two sets of objects. One set of objects is the reference, and the other set of objects is the difference. Compare-Object checks for available methods of comparing a whole object.
The Input Object is being truncated by the default display. To save the entire line to a file:
compare-object (get-content $File1) (get-content $File2) | format-list | Out-File $Location
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With