Wednesday, June 13, 2012

Finding MD5 of file in Powershell

You can find the MD5 of a file within Powershell using just a one liner. Here goes:

[BitConverter]::ToString((new-object Security.Cryptography.MD5CryptoServiceProvider).ComputeHash((new-object IO.FileInfo("c:\Path\ToFile.exe")).OpenRead())).Replace("-","").ToLower()

2 comments:

Anonymous said...

Best solution I found in the net!! Every time again, I am surprised what is possible in powershell. It resembles me of good old cmd64 ages ... ;-)

Bogi

Reuben Bartolo said...

Welcome! Here to help! :)