在 MD5 Powershell 中获取哈希

MK

我正在尝试制作一个脚本,该脚本可以获取我使用 ChildItem 函数获得的文件和目录的哈希 MD5。我目前的脚本如下。为什么哈希的一部分不起作用?

 $UserInput = Read-Host



 Get-ChildItem -Path $UserInput -Recurse  


function md5hash($UserInput)
{
    $fullPath = Resolve-Path $UserInput
    $md5 = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
    $file = [System.IO.File]::Open($fullPath,[System.IO.Filemode]::Open, [System.IO.FileAccess]::Read)
    [System.BitConverter]::ToString($md5.ComputeHash($file))
    $file.Dispose()
}
k7s5a

作为单线:

Get-ChildItem -Path C:\Temp -Recurse -File | Get-Filehash -Algorithm MD5

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章