Removing duplicates from a CSV file ( NOT unique values )

Ask your 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.
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Removing duplicates from a CSV file ( NOT unique values )

Post by apowershelluser »

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
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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

Post by jvierra »

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
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

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

Post by apowershelluser »

Hmm, that didn't really do what I was hoping, but I found a work around.. Thanks so much!
This topic is 4 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked