# This script is refered by other scripts. # You must put this in the PowerShell search path. function getMd5sum { param($Path) $md5str = "" if (Test-Path -PathType Leaf $Path) { $fi = Get-Item $Path $fs = New-Object IO.FileStream -ArgumentList $fi.FullName, "Open", "Read" $md5sb = New-Object Text.StringBuilder $md5obj = [Security.Cryptography.MD5]::Create() $md5bytes = $md5obj.ComputeHash($fs) $fs.Close() foreach ($eb in $md5bytes) { [void] $md5sb.Append($eb.ToString("x2")) } $md5str = $md5sb.ToString() + " " + $fi.Name } else { $md5str = "No such file: " + $Path } return $md5str } getMd5sum($args[0])