You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the win_powershell module, when using pwsh as the executable, the module fails to respect the depth parameter when converting $Ansible.Result values.
>$PSVersionTable
Name Value
---------
PSVersion 7.4.4
PSEdition Core
GitCommitId 7.4.4
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
STEPS TO REPRODUCE
Pass any nested .NET object(s) to the $Ansible.Result variable. If a simple hashtable is passed to $Ansible.Result, the issue does not arise (output is successfully converted as expected). The output returned by the script (e.g.: via return $output instead of $Ansible.Result = $output), the output appears to always be converted successfully. The issue only arises with the following factors:
The value is passed to $Ansible.Result
The value is a nested object (not hashtable or simple type such as int/string)
The win_powershell module should convert the return data from the $Ansible.Result ({ result: {} } in the task output) variable to the depth defined by the depth parameter (in this case: 5). The below is the result when executable: pwsh is not used. Both outputandresult are converted to the correct depth.
The below is the result when executable: pwshis used. While the output value was converted to the appropriate depth, the result value was not converted at all.
This sounds like it might be due to the serialization depth that is set by default. Will have to look into how that can be controlled so we can use our own custom depth value.
SUMMARY
In the
win_powershell
module, when usingpwsh
as the executable, the module fails to respect thedepth
parameter when converting$Ansible.Result
values.ISSUE TYPE
COMPONENT NAME
win_powershell
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Windows 10 v20.05
STEPS TO REPRODUCE
Pass any nested .NET object(s) to the
$Ansible.Result
variable. If a simple hashtable is passed to$Ansible.Result
, the issue does not arise (output is successfully converted as expected). The output returned by the script (e.g.: viareturn $output
instead of$Ansible.Result = $output
), theoutput
appears to always be converted successfully. The issue only arises with the following factors:$Ansible.Result
EXPECTED RESULTS
The
win_powershell
module should convert the return data from the$Ansible.Result
({ result: {} }
in the task output) variable to the depth defined by thedepth
parameter (in this case:5
). The below is the result whenexecutable: pwsh
is not used. Bothoutput
andresult
are converted to the correct depth.ACTUAL RESULTS
The below is the result when
executable: pwsh
is used. While theoutput
value was converted to the appropriate depth, theresult
value was not converted at all.The text was updated successfully, but these errors were encountered: