From 97744b2dc0e21b885dfc2a0e12e03887ebb052b6 Mon Sep 17 00:00:00 2001 From: schwartzmx Date: Tue, 14 Apr 2015 23:51:02 -0500 Subject: [PATCH] fixes unzip bug for zip files, thanks to @ryanwalls - also fixes possible import errors, and switches to use Start-Process on install to correctly wait --- lib/ansible/modules/extras/windows/win_unzip.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/extras/windows/win_unzip.ps1 b/lib/ansible/modules/extras/windows/win_unzip.ps1 index f31a6273a3..8e6db762fe 100644 --- a/lib/ansible/modules/extras/windows/win_unzip.ps1 +++ b/lib/ansible/modules/extras/windows/win_unzip.ps1 @@ -33,7 +33,7 @@ If ($params.src) { Fail-Json $result "src file: $src does not exist." } - $ext = [System.IO.Path]::GetExtension($dest) + $ext = [System.IO.Path]::GetExtension($src) } Else { Fail-Json $result "missing required argument: src" @@ -93,7 +93,7 @@ Else { If (-Not ($list -match "PSCX")) { # Try install with chocolatey Try { - cinst -force PSCX + cinst -force PSCX -y $choco = $true } Catch { @@ -109,9 +109,7 @@ Else { Fail-Json $result "Error downloading PSCX from $url and saving as $dest" } Try { - msiexec.exe /i $msi /qb - # Give it a chance to install, so that it can be imported - sleep 10 + Start-Process -FilePath msiexec.exe -ArgumentList "/i $msi /qb" -Verb Runas -PassThru -Wait | out-null } Catch { Fail-Json $result "Error installing $msi" @@ -127,7 +125,12 @@ Else { # Import Try { If ($installed) { - Import-Module 'C:\Program Files (x86)\Powershell Community Extensions\pscx3\pscx\pscx.psd1' + Try { + Import-Module 'C:\Program Files (x86)\Powershell Community Extensions\pscx3\pscx\pscx.psd1' + } + Catch { + Import-Module PSCX + } } Else { Import-Module PSCX