From 34ff61e24f99e4a97ab28dbcb15e60a4b1026791 Mon Sep 17 00:00:00 2001 From: Corwin Brown Date: Fri, 9 Oct 2015 17:49:34 -0500 Subject: [PATCH] Made Powershell Strict Complient --- .../modules/extras/windows/win_unzip.ps1 | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/extras/windows/win_unzip.ps1 b/lib/ansible/modules/extras/windows/win_unzip.ps1 index a62f246f5c8..1214bbaa89e 100644 --- a/lib/ansible/modules/extras/windows/win_unzip.ps1 +++ b/lib/ansible/modules/extras/windows/win_unzip.ps1 @@ -26,14 +26,14 @@ $result = New-Object psobject @{ changed = $false } -If ($params.creates) { +If (Get-Member -InputObject $params -Name creates) { If (Test-Path $params.creates) { Exit-Json $result "The 'creates' file or directory already exists." } } -If ($params.src) { +If (Get-Member -InputObject $params -Name src) { $src = $params.src.toString() If (-Not (Test-Path -path $src)){ @@ -62,24 +62,26 @@ Else { Fail-Json $result "missing required argument: dest" } -If ($params.recurse) { +If (Get-Member -InputObject $params -Name recurse) { $recurse = ConvertTo-Bool ($params.recurse) } Else { $recurse = $false } -If ($params.rm) { - $rm = ConvertTo-Bool ($params.rm) -} -Else { - $rm = $false +If (Get-Member -InputObject $params -Name rm) { + $rm = ConvertTo-Bool ($params.rm) +} +Else { + $rm = $false } If ($ext -eq ".zip" -And $recurse -eq $false) { Try { $shell = New-Object -ComObject Shell.Application - $shell.NameSpace($dest).copyhere(($shell.NameSpace($src)).items(), 20) + $zipPkg = $shell.NameSpace($src) + $destPath = $shell.NameSpace($dest) + $destPath.CopyHere($zipPkg.Items()) $result.changed = $true } Catch { @@ -154,4 +156,4 @@ Set-Attr $result.win_unzip "src" $src.toString() Set-Attr $result.win_unzip "dest" $dest.toString() Set-Attr $result.win_unzip "recurse" $recurse.toString() -Exit-Json $result; \ No newline at end of file +Exit-Json $result;