Dec 21 2014

Print this Post

Compare contents of two folders using PowerShell Get-FileHash

I needed to check that two folders are identical using a hash algorithm. Luckily enough, PowerShell 4.0 came equipped with a new cmdlet, Get-FileHash.

This easy command can produce a hash for any file using an array of different algorithms. One issue is when comparing with, Compare-Object, the difference in folder paths will be an issue. This is solved by removing the first part of the path. See below,


If the folders are identical, you should expect no output. Otherwise you will get a list of differences, either missing files or changed ones.

Happy file hashing!

About the author

Walid AlMoselhy

Permanent link to this article: http://almoselhy.azurewebsites.net/2014/12/compare-contents-of-two-folders-using-powershell-get-filehash/

Leave a Reply

Your email address will not be published. Required fields are marked *