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

win_file_version: Clean up and check-mode support (#21379)

* win_file_version: Clean up parameter handling and $result hash

Changes include:
- Replacing $result PSObject with hash
- Use Gt-AnsibleParam using -type

* Revert to original formatting
This commit is contained in:
Dag Wieers 2017-02-24 08:35:19 +01:00 committed by Matt Davis
parent 69ac88176d
commit 582557bc09

View file

@ -19,14 +19,14 @@
# WANT_JSON
# POWERSHELL_COMMON
$params = Parse-Args $args;
$params = Parse-Args $args -supports_check_mode $true
$result = New-Object psobject @{
win_file_version = New-Object psobject
$result = @{
win_file_version = @{}
changed = $false
}
$path = Get-AnsibleParam $params "path" -type "path" -failifempty $true -resultobj $result
$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true -resultobj $result
If (-Not (Test-Path -Path $path -PathType Leaf)){
Fail-Json $result "Specfied path $path does exist or is not a file."
@ -67,12 +67,11 @@ Catch{
Fail-Json $result "Error: $_.Exception.Message"
}
Set-Attr $result.win_file_version "path" $path.toString()
Set-Attr $result.win_file_version "file_version" $file_version.toString()
Set-Attr $result.win_file_version "product_version" $product_version.toString()
Set-Attr $result.win_file_version "file_major_part" $file_major_part.toString()
Set-Attr $result.win_file_version "file_minor_part" $file_minor_part.toString()
Set-Attr $result.win_file_version "file_build_part" $file_build_part.toString()
Set-Attr $result.win_file_version "file_private_part" $file_private_part.toString()
$result.win_file_version.path = $path.toString()
$result.win_file_version.file_version = $file_version.toString()
$result.win_file_version.product_version = $product_version.toString()
$result.win_file_version.file_major_part = $file_major_part.toString()
$result.win_file_version.file_minor_part = $file_minor_part.toString()
$result.win_file_version.file_build_part = $file_build_part.toString()
$result.win_file_version.file_private_part = $file_private_part.toString()
Exit-Json $result;