I'm trying to get the groups an ActiveDirectory Computer-Object belongs to sorted. To get the group listing I use the following code (in this case for PC123):
Get-adcomputer 'PC123' -properties Memberof | Select-Object -ExpandProperty MemberOf
I get the following output and as expected the groups are not sorted:
CN=(A) Group3,OU=OU-Path1,OU=OU-Path2,DC=domain,DC=local
CN=(A) Group1,OU=OU-Path1,OU=OU-Path2,DC=domain,DC=local
CN=(A) Group4,OU=OU-Path1,OU=OU-Path2,DC=domain,DC=local
CN=(A) Group2,OU=OU-Path1,OU=OU-Path2,DC=domain,DC=local
I tried to sort using Sort-Object:
Get-adcomputer 'PC215' -properties Memberof | Select-Object -ExpandProperty MemberOf | Sort-Object -Property Memberof
Unfortunately the output stays the same. I tried fooling around a bit by changing the position of Sort-Object -Property Memberof but that does not seem to be the problem. Any hints would be appreciated.