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

Made Powershell Strict Complient

This commit is contained in:
Corwin Brown 2015-10-09 17:49:34 -05:00 committed by Matt Clay
parent e0e45bd383
commit 34ff61e24f

View file

@ -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;
Exit-Json $result;