summaryrefslogtreecommitdiff
path: root/windows/win_file_version.ps1
diff options
context:
space:
mode:
authornitzmahone <mdavis@ansible.com>2016-03-10 13:16:07 -0800
committernitzmahone <mdavis@ansible.com>2016-03-10 13:16:07 -0800
commitc8137a47e284c8cdafe128d5a6a9a01864df4bbd (patch)
treec40302555c2b93bc98597c4b7e25fbf6b0d3b505 /windows/win_file_version.ps1
parent6456484eb33ef5886ae549155a2b974f32a1db62 (diff)
downloadansible-modules-extras-c8137a47e284c8cdafe128d5a6a9a01864df4bbd.tar.gz
fix default arg handling and error messages in win_file_version
Diffstat (limited to 'windows/win_file_version.ps1')
-rw-r--r--windows/win_file_version.ps117
1 files changed, 6 insertions, 11 deletions
diff --git a/windows/win_file_version.ps1 b/windows/win_file_version.ps1
index d3e17f14..2e2f341c 100644
--- a/windows/win_file_version.ps1
+++ b/windows/win_file_version.ps1
@@ -26,19 +26,14 @@ $result = New-Object psobject @{
changed = $false
}
+$path = Get-AnsibleParam $params "path" -failifempty $true -resultobj $result
-If ($params.path) {
- $path = $params.path.ToString()
- If (-Not (Test-Path -Path $path -PathType Leaf)){
- Fail-Json $result "Specfied path: $path not exists or not a file"
- }
- $ext = [System.IO.Path]::GetExtension($path)
- If ( $ext -notin '.exe', '.dll'){
- Fail-Json $result "Specfied path: $path is not a vaild file type, Must be DLL or EXE."
- }
+If (-Not (Test-Path -Path $path -PathType Leaf)){
+ Fail-Json $result "Specfied path $path does exist or is not a file."
}
-Else{
- Fail-Json $result "Specfied path: $path not define."
+$ext = [System.IO.Path]::GetExtension($path)
+If ( $ext -notin '.exe', '.dll'){
+ Fail-Json $result "Specfied path $path is not a vaild file type; must be DLL or EXE."
}
Try {