Hello. I have an array of objects with three properties as shown below:
PS C:\Windows\system32> $array_objects
User IP Account
SYSTEM 192.168.137.1 local
SYSTEM 192.168.137.1 local
SYSTEM 192.168.137.2 local
admin 172.16.2.1 domain
admin 172.16.2.1 domain
Some objects have the same User and IP property. I would like to return a unique array of objects based on the User and IP properties and later be able to access all three properties of this array of objects.
I have been able to find the unique array of objects using the Group-Object cmdlet below:
PS C:\Windows\system32> $array_objects = $array_objects | Group-Object -Property "User","IP" | Select -ExpandProperty Name PS C:\Windows\system32> $array_objects
However, the output of the above command only returns the two grouped properties I cannot access the third property from this new object. I do not want to also group on the third property, I just want to be able to access it like $array_objects[0].Account
Is there another way to find the unique objects based on the User and IP properties, while still being able to access its third property?