I've searched all over and I think this would be fairly common but maybe not.
I want to list the domain of a user with the username via Get-ADGroupMember. So for instance I have this:
Get-ADGroupMember -identity "MyGroup" -Recursive -Server "my.domain.net" | select-object SamAccountName
SamAccountName -------------- jsmith dsmith lsmith
I want that list to return the users primary domain so for instance I have the domains
prod.my.domain.net dev.my.domain.net my.domain.net
I want a query that will return
prod\jsmith dev\dsmith my\lsmith
depending on the users domain (note order of names does not matter).