Verifying Checksums in PowerShell

Hello Windows admin! So you’ve downloaded some software from the interwebz and you don’t know if it’s safe! All those holier-than-thou Linux admins have their MD5 checksum tools, and good news everyone, you do too!

Since PowerShell v5.1 , you’re able to use a function called Get-FileHash. With this tool you can verify file hashes to your hearts content!

Get-FileHash

In the example below, we’ve downloaded an Ubuntu server ISO to the Downloads folder. The Ubuntu download page has provided the checksum in sha256:

1.png

We can simply copy the checksum from the page, and assign it to a variable.


Then we can use Get-FileHash with SHA256 using Select-Object -ExpandProperty to filter the object down to just the string returned.

4.png


Last, we compare $hash with $ubuntuHash and can see that the hash provided by the download site and the hash computed by PowerShell match!

Happy PowerShell-ing!