Powershell Sort-Object -Unique

Viewed 1692

I have an array which contains a variety of TaskNumbers and I am trying to obtain the members which are unique and those which are non-unique(as I have to take different actions for each)

Now, if I use Sort-Object -Property TaskNumber -Unique, it returns 1 non-unique value for each set of non-unique values it finds(See TK-15386 below). I need to actually get the values that are unique, as opposed to one result being included that is in reality not unique at all. Even if I could flag this solo returned non-unique value in some way I could account for it later on. Anyone got any ideas? Am using PS v4 but could upgrade if there is a fix somehow in v5.

$Thisweekarray | Select-Object -Property TaskNumber | Sort-Object -Property TaskNumber 

TK-02213                                                                                                                                                                             
TK-02242                                                                                                                                                                             
TK-15386                                                                                                                                                                             
TK-15386                                                                                                                                                                             
TK-15386                                                                                                                                                                             
TK-15386                                                                                                                                                                             
TK-15387                                                                                                                                                                             

$Thisweekarray | Select-Object -Property TaskNumber | Sort-Object -Property TaskNumber -Unique                                                                                                                                                                          

TK-02213                                                                                                                                                                             
TK-02242                                                                                                                                                                             
TK-15386                                                                                                                                                                             
TK-15387 
1 Answers
Related