mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Merge pull request #8793 from cchurch/powershell3_compat
Replace Get-FileHash with MD5 code that works on PowerShell 3.
This commit is contained in:
@@ -89,7 +89,10 @@ class ShellModule(object):
|
||||
script = '''
|
||||
If (Test-Path -PathType Leaf "%(path)s")
|
||||
{
|
||||
(Get-FileHash -Path "%(path)s" -Algorithm MD5).Hash.ToLower();
|
||||
$sp = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
|
||||
$fp = [System.IO.File]::Open("%(path)s", [System.IO.Filemode]::Open, [System.IO.FileAccess]::Read);
|
||||
[System.BitConverter]::ToString($sp.ComputeHash($fp)).Replace("-", "").ToLower();
|
||||
$fp.Dispose();
|
||||
}
|
||||
ElseIf (Test-Path -PathType Container "%(path)s")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user