The difference between Get-Unique and select-object -unique

Using PowerShell, I import csv data from a file through "import-csv" into the $ csvList object. This csv data has a Benutzer column. By doing something like this:

$csvList | %{$_.Benutzer} | select-object -unique

there is nothing special: as expected, unique records are returned in Benutzer, which are about 10 elements. However

$csvList | %{$_.Benutzer} | get-unique -asstring

or

$csvList | Group($_.Benutzer)

seems to treat each record as unqiue, i.e. the entire 260 Benutzer array is returned in case of get-unique and 260 groups are created in the case of a group operator. I am using PowerShell 4.0.

Any idea what is going on here is appreciated ...

+4
source share
1 answer

From the Get-Uniquereference:

Get-Unique ...

Select-Object -Unique .

:

PS> 9,8,9,8 | Get-Unique -AsString
9
8
9
8

:

PS> 9,8,9,8 | Sort-Object -Unique
8
9

Group-Object, , ($_.Benutzer) Benutzer:

$csvList | Group-Object Benutzer
+6

All Articles