Q. How can I remove duplicates from a list of entries?

Use the Select-Object cmdlet's -unique parameter. Here are some examples and instructions.

Don Jones

August 3, 2010

1 Min Read
two rows of computers sitting on grass

Q. How can I remove duplicates from a list of entries?

A. Use the Select-Object cmdlet's -unique parameter. For example, to eliminate duplicate event log entries in a list, you'd use the command:

Get-EventLog -Log Security -Newest 100 | Select -Property EventID -Unique

 

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like