my $PSVersionTable output is as follows:
Name Value
---- -----
PSVersion 7.0.1
PSEdition Core
GitCommitId 7.0.1
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
If I enter
wsl -l | Get-Member
the output informs me that the output type is a String.
If I enter
(wsl -l).GetType()
the output informs me that the output type is Array.
The entire reason I'm looking at this is that I was trying to parse the output of that command and for a long, frustrating time, I was thinking that I was working with a single, contiguous string with embedded carriage return / line feeds, but it appears I'm actually working with an array of strings.
So my question: what do the parentheses around the command do to seemingly change the nature of the output of the executable? Is it that without the parentheses the output from 'wsl -l' is being streamed to Get-Member one line (array element) at a time?
Thank you!
$var = wsl -l$var.gettype()$var.GetType().basetype.name Array|enumerates the contents of the array, andGet-Memberonly shows output once per distinct input type - both expressions resolve to an array containing strings :)wsl -loutputs a single line, you will have a string. Otherwise it's an array.