Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
2ddab7af
Commit
2ddab7af
authored
Aug 28, 2014
by
Chris Church
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8793 from cchurch/powershell3_compat
Replace Get-FileHash with MD5 code that works on PowerShell 3.
parents
b7082677
0d1197a9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
lib/ansible/runner/shell_plugins/powershell.py
+4
-1
library/windows/win_stat.ps1
+5
-2
No files found.
lib/ansible/runner/shell_plugins/powershell.py
View file @
2ddab7af
...
...
@@ -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")
{
...
...
library/windows/win_stat.ps1
View file @
2ddab7af
...
...
@@ -53,8 +53,11 @@ Else
If
(
$get_md5
-and
$result
.stat.exists -and -not
$result
.stat.isdir
)
{
$path_md5
=
(
Get-FileHash
-Path
$path
-Algorithm MD5
)
.Hash.ToLower
()
;
Set
-Attr
$result
.stat
"md5"
$path_md5
;
$sp
=
new-object
-TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
$fp
=
[
System.IO.File]::Open
(
$path
,
[
System.IO.Filemode]::Open,
[
System.IO.FileAccess]::Read
)
;
$hash
=
[
System.BitConverter]::ToString
(
$sp
.ComputeHash
(
$fp
))
.Replace
(
"-"
,
""
)
.ToLower
()
;
$fp
.Dispose
()
;
Set
-Attr
$result
.stat
"md5"
$hash
;
}
Exit
-Json
$result
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment