Removing duplicates from a CSV file ( NOT unique values )

Ask your Windows PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Post Reply
User avatar
JohnTitor
Posts: 149
Joined: Fri Nov 17, 2017 8:49 pm

Removing duplicates from a CSV file ( NOT unique values )

Post by JohnTitor » Wed Jun 12, 2019 10:11 am

I have a spreadsheet for lockouts. This lists mac addresses and a few other things

On the macaddress columns, it lists the MACs for their PC, phone, tablet, etc...
Sometimes this CSV file list the same mac addresses multiple times because the phone pings our wireless in attempt to reconnect and their PCs have stored managed credentials

What I'm looking for is the powershell way in excel for Remove Duplicates

When I choose -unique, well it gives me just one :D

User avatar
jvierra
Posts: 13571
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Removing duplicates from a CSV file ( NOT unique values )

Post by jvierra » Wed Jun 12, 2019 10:25 am

Excel has a deduplicating method built in. Just select what you want to dedupe and click the button.

In a CSV (a csv is not an Excel workbook it can just be viewed as such) you can use "Group-Object" to dedupe a Csv,

help group-object -online

User avatar
JohnTitor
Posts: 149
Joined: Fri Nov 17, 2017 8:49 pm

Re: Removing duplicates from a CSV file ( NOT unique values )

Post by JohnTitor » Thu Jun 13, 2019 7:55 am

Hmm, that didn't really do what I was hoping, but I found a work around.. Thanks so much!

Post Reply