PowerShell Cryptographic Hash Checker

I decided to build a little cryptographic hash checker in PowerShell leveraging some built-in cmdlets and other functions. While there are lots of tools that already do this, many with very nice GUIs I decided it would be fun to build one of my own. The newly made cmdlet is very simple. You select what cryptographic hash algorithm you want to use (MD5, SHAx) and then provide the function with the original hash. Next you select the file you want to compare and it tells you whether the two hashes are a match.

I’m no coding expert so I’m sure this could be streamlined and optimised and this is something I do intend to do, especially to make it work nicely on a Windows Server Core installation where the Explorer file select menu call doesn’t work.

If anyone wishes to comment or provide feedback please feel free to comment below or drop me a message on Twitter.


Assume we have downloaded a file from a website/internal file server and we wish to check it is as expected. In my case I will use a simple text file called ‘Test.txt’.

  • Test.txt SHA1 hash = 26D82F1931CBDBD83C2A6871B2CECD5CBCC8C26B

Next I will run my function, selecting SHA1 as the hashing mechanism and then selecting the test file.

Now I will run the same test but I will enter a different hash to emulate some form of corruption or other change resulting in a hash mismatch.

As you can see it’s a pretty basic system. The Microsoft get-filehash cmdlet does of course provide you with a hash but I wanted a nice way to easily compare the value as well as something I can give to a ‘lay’ person at work who may need to do this regularly but without having to install extra software or learn PowerShell cmdlet usage.

Below is the full function –


I have added a few comments but I think it’s pretty self explanatory for the most part – if not let me know!

1 thought on “PowerShell Cryptographic Hash Checker

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.