LoginSignup
2
1

More than 5 years have passed since last update.

ディレクトリ配下のファイルに対して、MD5ハッシュ値を取得する

Posted at

指定されたディレクトリ配下のファイルに対して、MD5ハッシュ値を取得するスクリプト

下記ブログを参考に作成
PowerShell でハッシュ値を計算する(http://blogs.gine.jp/taka/archives/1369)

GetMD5.ps1
param($path)

function GetMD5{
    param($fileName)

    $stream = New-Object IO.StreamReader $fileName

    # MD5ハッシュ値を計算する
    $md5 = [System.Security.Cryptography.MD5]::Create()
    $hash = $md5.ComputeHash($stream.BaseStream);
    $result = [System.BitConverter]::ToString($hash).Replace("-","").ToLower()

    $result
}

Get-ChildItem $path  | ?{ !$_.PSIsContainer } |
%{
    echo ($_.Name + "`t" + (GetMD5 $_.FullName))
}
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1