我正在尝试制作一个脚本,该脚本可以获取我使用 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()
}
作为单线:
Get-ChildItem -Path C:\Temp -Recurse -File | Get-Filehash -Algorithm MD5
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句