I have a file with the following columns: RecipientAddress and MessageId
I need to get only conntent with unique RecipientAddress. If I run:
Import-Csv $File_MsgList | select RecipientAddress | Sort-Object RecipientAddress | Get-Unique -AsString
It filters out the duplicates correctly. But If I want to get the associated MessageId as well, it is not able to remove the duplicate addresses anymore.
Import-Csv $File_MsgList | select RecipientAddress, MessageId | Sort-Object RecipientAddress | Get-Unique -AsString
How can I get both columns as well as get uniques on the first column?
Group-Objectfor this purpose. You'd get unique RecipientAddresses with their associated message IDs.