DEV Community

taijidude
taijidude

Posted on

filter duplicates from arrays

Hello again, it's been a while. Have several things on my plate, so it's only a short post again.

If you want to get rid of duplicates in a powershell array you have to pipe the array into a select keyword with a -Unique parameter.

@("1","2", "3", "4", "2", "2", "2", "2", "5") | select -Unique
Enter fullscreen mode Exit fullscreen mode

It will give you the following result:

Alt Text

Top comments (0)