Powershell File Compare

Viewed 28432

I am using a PowerShell script to move some files around on some servers. I want to test if a file I am going to move already exists in the destination. Not just a file with the same name.

I thought

Compare-Object $File1 $File2
Should do it but no matter what the files are it always returns that they are the same eg.

InputObject           SideIndicator                              
-----------           -------------                              
D:\1.gif               =>                                         
D:\1.wma               <=    

Is there some other way to test if two files are identical?

6 Answers
(Get-FileHash $path1).Hash -eq (Get-FileHash $path2).Hash
Related