I have the following code.
$l = @("A", "B", "X", "Y")
echo "A,B,X`n1,2,3,4" > .\myFile # Create test file
$f = cat myFile | ConvertFrom-Csv | gm -MemberType NoteProperty | select Name
compare $l $f
$a = .... # convert $f to array
compare $l $a
How to convert the $f
to array so it can be compared with an array? Bracing @(...)
doesn't work.
I got the following result when compare $l
and $f
.
PS C:\Users\nick> compare $l $f
InputObject SideIndicator
----------- -------------
@{Name=A} =>
@{Name=B} =>
@{Name=X} =>
A <=
B <=
X <=
Y <=
Replace select Name
with select -Expand Name
or ForEach-Object { $_.Name }
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With