mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Applying bf916fb5
fix to v2
This commit is contained in:
parent
805e83d209
commit
93cc08e613
1 changed files with 22 additions and 0 deletions
|
@ -142,3 +142,25 @@ Function ConvertTo-Bool
|
|||
return
|
||||
}
|
||||
|
||||
# Helper function to calculate md5 of a file in a way which powershell 3
|
||||
# and above can handle:
|
||||
Function Get-FileMd5($path)
|
||||
{
|
||||
$hash = ""
|
||||
If (Test-Path -PathType Leaf $path)
|
||||
{
|
||||
$sp = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
|
||||
$fp = [System.IO.File]::Open($path, [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
|
||||
[System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
|
||||
$fp.Dispose();
|
||||
}
|
||||
ElseIf (Test-Path -PathType Container $path)
|
||||
{
|
||||
$hash= "3";
|
||||
}
|
||||
Else
|
||||
{
|
||||
$hash = "1";
|
||||
}
|
||||
return $hash
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue