I have created a PSObject with multiple properties. I would like to remove duplicate entries from the PSObject using a specific property as a reference.
I'd like to do this while keeping the PSObject in its original format.
Examples I have seen extract the non-duplicate values. I want to delete the duplicate values.
I'm trying to turn this:
DistinguishedName Name
----------------- ----
OU=Users,DC=Domain,DC=Local Users
OU=Users,DC=Domain,DC=Local Users
Into this:
DistinguishedName Name
----------------- ----
OU=Users,DC=Domain,DC=Local Users
I have a feeling i'm missing a trick here...
Thanks
That looks like the Format-Table
output of a collection of PSObjects with the same properties.
To weed out duplicates, use Sort-Object -Unique
:
$uniqObjects = $psobjects |Sort-Object -Unique