1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

This commit is contained in:
schwartzmx 2015-04-14 23:51:02 -05:00 committed by Matt Clay
parent 6439c96b2b
commit 97744b2dc0

View file

@ -33,7 +33,7 @@ If ($params.src) {
Fail-Json $result "src file: $src does not exist." Fail-Json $result "src file: $src does not exist."
} }
$ext = [System.IO.Path]::GetExtension($dest) $ext = [System.IO.Path]::GetExtension($src)
} }
Else { Else {
Fail-Json $result "missing required argument: src" Fail-Json $result "missing required argument: src"
@ -93,7 +93,7 @@ Else {
If (-Not ($list -match "PSCX")) { If (-Not ($list -match "PSCX")) {
# Try install with chocolatey # Try install with chocolatey
Try { Try {
cinst -force PSCX cinst -force PSCX -y
$choco = $true $choco = $true
} }
Catch { Catch {
@ -109,9 +109,7 @@ Else {
Fail-Json $result "Error downloading PSCX from $url and saving as $dest" Fail-Json $result "Error downloading PSCX from $url and saving as $dest"
} }
Try { Try {
msiexec.exe /i $msi /qb Start-Process -FilePath msiexec.exe -ArgumentList "/i $msi /qb" -Verb Runas -PassThru -Wait | out-null
# Give it a chance to install, so that it can be imported
sleep 10
} }
Catch { Catch {
Fail-Json $result "Error installing $msi" Fail-Json $result "Error installing $msi"
@ -127,8 +125,13 @@ Else {
# Import # Import
Try { Try {
If ($installed) { If ($installed) {
Try {
Import-Module 'C:\Program Files (x86)\Powershell Community Extensions\pscx3\pscx\pscx.psd1' Import-Module 'C:\Program Files (x86)\Powershell Community Extensions\pscx3\pscx\pscx.psd1'
} }
Catch {
Import-Module PSCX
}
}
Else { Else {
Import-Module PSCX Import-Module PSCX
} }