PowerShell で、指定したフォルダー配下のファイルハッシュ値を取得する方法についての備忘録。
■ 取得した値を表示するコマンド
Get-ChildItem "C:\Windows" -File -Recurse | Get-FileHash -Algorithm md5 | Select-Object -Property "Path", "Hash"
■ 表示結果
Path Hash
---- ----
C:\Windows\ActiveXVersion.ocx 3296A0C5305EEE19B5F45F3979618BE5
C:\Windows\ActiveXVersionEG.ocx EB8CCD1F6C3A2B318CE8B75AC54A5282
C:\Windows\bfsvc.exe 341186916B37AA2CBF4EE5423338F704
C:\Windows\CLHSCsvXtx.dll 9F766E6261F168CDD22E85BCBE845BE0
C:\Windows\CLInitialize.dll 6839CA8AAB82182D80B92331E6F45CC9
C:\Windows\CLIsaXtx.dll 18A9CB4769522FD70169C21A7A1F0D57
C:\Windows\CLTenpuImageXtx.dll CDFE103E94D5C8EAAF134362092FB713
C:\Windows\CLXtxSigner.dll BE355372E9E04D8093EA108EC17A5205
C:\Windows\cmapi.dll 58BE5DC6B08DEC23E9DC148193A7F88A
C:\Windows\cmlasn.dll 42432FED13919F47C4016802380D845E
~ 以下省略 ~
■ ファイルに保存するには
Get-ChildItem "C:\Windows" -File -Recurse | Get-FileHash -Algorithm md5 | Select-Object -Property "Path", "Hash" | export-csv "C:\TMP\Winodws.CSV" -Encoding Default -NoTypeInformation
■ 出力結果
"Path","Hash"
"C:\Windows\ActiveXVersion.ocx","3296A0C5305EEE19B5F45F3979618BE5"
"C:\Windows\ActiveXVersionEG.ocx","EB8CCD1F6C3A2B318CE8B75AC54A5282"
"C:\Windows\bfsvc.exe","341186916B37AA2CBF4EE5423338F704"
"C:\Windows\CLHSCsvXtx.dll","9F766E6261F168CDD22E85BCBE845BE0"
"C:\Windows\CLInitialize.dll","6839CA8AAB82182D80B92331E6F45CC9"
"C:\Windows\CLIsaXtx.dll","18A9CB4769522FD70169C21A7A1F0D57"
"C:\Windows\CLTenpuImageXtx.dll","CDFE103E94D5C8EAAF134362092FB713"
"C:\Windows\CLXtxSigner.dll","BE355372E9E04D8093EA108EC17A5205"
"C:\Windows\cmapi.dll","58BE5DC6B08DEC23E9DC148193A7F88A"
"C:\Windows\cmlasn.dll","42432FED13919F47C4016802380D845E"
~ 以下省略 ~