Home » Questions » Computers [ Ask a new question ]

How can Powershell on Windows 7 diff two files?

How can Powershell on Windows 7 diff two files?

Can Powershell on Windows 7 diff two files on the hard drive?

Asked by: Guest | Views: 323
Total answers/comments: 1
bert [Entry]

"Edit: Apparently there is a built in alias so this works too:

diff $(Get-Content C:\file1.txt) $(Get-Content C:\file2.txt)

You can do this:

Compare-Object $(Get-Content c:\file1.txt) $(Get-Content c:\file2.txt)

This is some sample output:

InputObject SideIndicator
----------- -------------
This is a line in file 2 =>
This is a line in file 1 <=

You can also do -excludeDifferent to only show the lines that are the same or -includeEqual to include the lines that are the same."