A. Getting a list with only unique values is easy with PowerShell. Pass your list of unique values to the Get-Unique cmdlet—as the following code shows—and PowerShell will output only the unique instance:
Users\john.SAVILLTECH> 1,1,1,1,2,2,2,3,4,4,4,4,5,6,6,6,7,7,7,7,4,5 | get-unique
The return is:
1
2
3
4
5
6
7
4
5
This return includes a duplicate 4 and duplicate 5 at the end. The cmdlet returned only unique values for adjacent values, which is how the cmdlet works. To avoid this problem, first use the Sort-Object cmdlet to sort the list, as in the following example:
Users\john.SAVILLTECH> 1,1,1,1,2,2,2,3,4,4,4,4,5,6,6,6,7,7,7,7,4,5 | sort-object | get-unique
Using the Sort-Object cmdlet, you'll get the following return:
1
2
3
4
5
6
7
End of Article