The following code results in an Array:
[Array]$Object = [PSCustomObject]@{
P1 = 'Appel'
P2 = 'Cherry'
P3 = 'Appel'
P4 = 'Banana'
}
$Object += [PSCustomObject]@{
P1 = 'Good'
P2 = 'Bad'
P3 = 'Good'
P4 = 'Good'
}
$Object += [PSCustomObject]@{
P1 = 'Green'
P2 = 'Red'
P3 = 'Green'
P4 = 'Yellow'
}
$Object
This generates:
P1 P2 P3 P4
-- -- -- --
Appel Cherry Appel Banana
Good Bad Good Good
Green Red Green Yellow
I'm trying to figure out how I can have it report the duplicates, in this case the desired outcome would be P1 and P3 as they both have the same info in them:
P1 P3
-- --
Appel Appel
Good Good
Green Green
Because the values are not in the same object it's not as simple as using Group-Object to retrieve them. Any help would be appreciated.
if (!(Compare-Object $object.p1 $object.p3)) { echo duplicate }?Compare-Object $Object.P1 $Object.P3 -IncludeEqual -ExcludeDifferent. I only need to figure out how to loop through the collection to have it compare everything.