two rows of computers sitting on grass

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

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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish