PowerShell Get-Ad Group Member


Can anyone please assist me on below script that I was using. I am able to extract the information of the users. The issue is it does not give the details if the user belongs to a different domain which is added on the group. Can anyone please point me what should I be doing to extract the information even if the user belongs to a different domain.

below is the script I manage so far:

Get-ADGroup "Group Members" | Get-ADGroupMember -Recursive | Get-ADUser -Properties * |
Select @{Name="Name";Expression={$_.DisplayName}},
@{Name="User ID";Expression={$_.SamAccountName}},
@{Name="Email";Expression={$_.EmailAddress}} |
Export-CSV C:\Users\Users\Desktop\Group-Members.csv -NoTypeInformation

Thanks in advance

Get-ADPrincipalGroupMembership will do this.

Get-ADPrincipalGroupMembership username | select name

Domain Users
Domain Computers
Workstation Admins
Company Users
Company Developers
1 Like