Using PowerShell, I import csv-data from file via "import-csv" into the object $csvList. This csv-data has a column called Benutzer. When doing something like this:
$csvList | %{$_.Benutzer} | select-object -unique
there is nothing special: as expected, the unique entries in Benutzer are returned, which are around 10 items. However,
$csvList | %{$_.Benutzer} | get-unique -asstring
or
$csvList | Group($_.Benutzer)
seem to treat each entry as unqiue, i.e. the entire array of 260 Benutzer is returned in case of get-unique and 260 groups are created in case of the group statement. I am using PowerShell 4.0.
Any idea what is going on here is appreciated...
From Get-Unique
help:
The Get-Unique cmdlet compares each item in a sorted list...
Select-Object -Unique
does not require objects to be pre-sorted.
Example:
PS> 9,8,9,8 | Get-Unique -AsString
9
8
9
8
Example:
PS> 9,8,9,8 | Sort-Object -Unique
8
9
As for Group-Object
, the syntax of the command should be different, replace ($_.Benutzer)
with the property name Benutzer
:
$csvList | Group-Object Benutzer
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