PowerShell Get-Ad Group Member

Hi

Can anyone please assist me with the script below that I was using? I am able to extract the information about the users. The issue is that it does not give the details if the user belongs to a different domain that is added to the group. Can anyone please point me to what I should do 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="WWID";Expression={$_.EmployeeID}},
@{Name="Designation";Expression={$_.Title}},
@{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

name
----
Domain Users
Domain Computers
Workstation Admins
Company Users
Company Developers
AutomatedProcessingTeam
1 Like