This works:
Get-Command $PSCommandPath | %{ $_.Parameters }
But this doesn't:
Get-Command $PSCommandPath | %{ $_.Parameters | %{ echo $_.Value } }
Why?
This works:
Get-Command $PSCommandPath | %{ $_.Parameters }
But this doesn't:
Get-Command $PSCommandPath | %{ $_.Parameters | %{ echo $_.Value } }
Why?
The Parameters property is a hash table (dictionary):
Get-Command $PSCommandPath | %{ $_.Parameters.GetType() }
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Dictionary`2 System.Object
The Powershell pipeline will automatically "unroll" arrays and collections, but not hash tables. If you want to foreachthrough the indivudual elements, you have to enumerate them expliclitly using .getenumerator().
Get-Command $PSCommandPath | %{ $_.Parameters.GetEnumerator() | % {echo $_.Value } }
echo $_.Value.ToString() emits: System.Management.Automation.ParameterMetadata instead of the parameter string value.. how can I output the parameter's text?System.Management.Automation.ParameterMetadataGet-Command $PSCommandPath | %{ $_.Parameters.GetEnumerator() | % { (Get-Variable $_.Key).Value } }