Remove duplicates

Often i need to remove duplicates in objects before pipe them to another function, or before print the result.

So, let’s take a cmdlet which return many lines like Get-Process










Now, let’s remove duplicates from the output… Two methods exist for this task…

The first one:





The second method:






Ok, which one should i use ? Kinda difficult to answer that, two of them return exactly the same output… The main difference between them is performance related, look at this !













Ok, we talk only about Milliseconds, but clearly on bigger objects collection it could be far better.

Hope you’ll find how to use this.

See ya!