From 092c3ccbde7062b20466fa980e5d749b2a61a1f6 Mon Sep 17 00:00:00 2001 From: nitzmahone Date: Thu, 10 Mar 2016 13:16:07 -0800 Subject: [PATCH] fix default arg handling and error messages in win_file_version --- .../modules/extras/windows/win_file_version.ps1 | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/ansible/modules/extras/windows/win_file_version.ps1 b/lib/ansible/modules/extras/windows/win_file_version.ps1 index d3e17f14800..2e2f341c461 100644 --- a/lib/ansible/modules/extras/windows/win_file_version.ps1 +++ b/lib/ansible/modules/extras/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 {