Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Last active December 27, 2015 19:29
Show Gist options
  • Save RyanHirsch/7377071 to your computer and use it in GitHub Desktop.
Save RyanHirsch/7377071 to your computer and use it in GitHub Desktop.
md5 hashing in Powershell
$pathToFile = $args[0].Substring(1)
$where = Get-Location
Function md5Hash($filePath)
{
$someFilePath = $filePath
$md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
$hash = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($someFilePath)))
return $hash
}
Write-Host (md5Hash $where$pathToFile)

Expected to live in a parent directory and then operate on files in child directories

PS C:\Releases> .\md5.ps1 .\App_v1\CompiledPackage.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment