summaryrefslogtreecommitdiff
path: root/windows/win_unzip.ps1
diff options
context:
space:
mode:
authorPhil <schwartzmx@gmail.com>2015-06-18 16:15:15 -0500
committerPhil <schwartzmx@gmail.com>2015-06-18 16:18:15 -0500
commit623a29cc0ecb00ddea636b89414517380a29d48b (patch)
tree437c2d08893b8b67f41a996353e278f26b50ea7e /windows/win_unzip.ps1
parentc6d56809670b8e486a7f9e420edce178dda8f543 (diff)
downloadansible-modules-extras-623a29cc0ecb00ddea636b89414517380a29d48b.tar.gz
update to not auto-install PSCX
- will use built-in powershell method instead for .zip files - added example for installing pscx as a pretask
Diffstat (limited to 'windows/win_unzip.ps1')
-rw-r--r--windows/win_unzip.ps152
1 files changed, 6 insertions, 46 deletions
diff --git a/windows/win_unzip.ps1 b/windows/win_unzip.ps1
index 8e6db762..35a55c81 100644
--- a/windows/win_unzip.ps1
+++ b/windows/win_unzip.ps1
@@ -1,7 +1,7 @@
#!powershell
# This file is part of Ansible
#
-# Copyright 2014, Phil Schwartz <schwartzmx@gmail.com>
+# Copyright 2015, Phil Schwartz <schwartzmx@gmail.com>
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -80,43 +80,13 @@ If ($ext -eq ".zip" -And $recurse -eq $false) {
Fail-Json $result "Error unzipping $src to $dest"
}
}
-# Need PSCX
+# Requires PSCX
Else {
- # Requires PSCX, will be installed if it isn't found
- # Pscx-3.2.0.msi
- $url = "http://download-codeplex.sec.s-msft.com/Download/Release?ProjectName=pscx&DownloadId=923562&FileTime=130585918034470000&Build=20959"
- $msi = "C:\Pscx-3.2.0.msi"
-
# Check if PSCX is installed
$list = Get-Module -ListAvailable
- # If not download it and install
+
If (-Not ($list -match "PSCX")) {
- # Try install with chocolatey
- Try {
- cinst -force PSCX -y
- $choco = $true
- }
- Catch {
- $choco = $false
- }
- # install from downloaded msi if choco failed or is not present
- If ($choco -eq $false) {
- Try {
- $client = New-Object System.Net.WebClient
- $client.DownloadFile($url, $msi)
- }
- Catch {
- Fail-Json $result "Error downloading PSCX from $url and saving as $dest"
- }
- Try {
- Start-Process -FilePath msiexec.exe -ArgumentList "/i $msi /qb" -Verb Runas -PassThru -Wait | out-null
- }
- Catch {
- Fail-Json $result "Error installing $msi"
- }
- }
- Set-Attr $result.win_zip "pscx_status" "pscx was installed"
- $installed = $true
+ Fail-Json "PowerShellCommunityExtensions PowerShell Module (PSCX) is required for non-'.zip' compressed archive types."
}
Else {
Set-Attr $result.win_zip "pscx_status" "present"
@@ -124,17 +94,7 @@ Else {
# Import
Try {
- If ($installed) {
- Try {
- Import-Module 'C:\Program Files (x86)\Powershell Community Extensions\pscx3\pscx\pscx.psd1'
- }
- Catch {
- Import-Module PSCX
- }
- }
- Else {
- Import-Module PSCX
- }
+ Import-Module PSCX
}
Catch {
Fail-Json $result "Error importing module PSCX"
@@ -193,4 +153,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;
+Exit-Json $result; \ No newline at end of file