Get AD Group Member - Different Domains
I found using get-adgroup -properties member to be more reliable for returning all objects.
To get objects from different domains I do the following:
get-adgroup -properties member | select -expand member | get-adobject
From this get the distinguished name of the object, this will tell you what domain to search, so in the end you should have something like:
get-aduser $user -server $foundDomainDC
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I've been tasked with exporting the members of a few AD groups to
.csv
which I've always done in the past using theGet-ADGroupMember
command in powershell, specifying the group name, selecting the property I need, and usingexport-csv
.
I seem to run into an issue with one group though which appears to be related to the fact that the AD group has members that belong to an external domain in a different forest. Essentially I run the following command below, but the output file comes out blank.Get-ADGroupMember -identity "VPN Users" | select name | Export-csv -path c:\vpnuserslist.csv -NoTypeInformation
The output is the following:
PS C:\Windows> Get-ADGroupMember -identity "VPN Users" | select name | Export-Csv -Path c:\vpnuserstest.csv -NoTypeInformation Get-ADGroupMember : The operation completed successfully At line:1 char:18 + Get-ADGroupMember <<<< -identity "VPN Users" | select name | Export-Csv -Path c:\vpnuserstest.csv -NoTypeInformation + CategoryInfo : NotSpecified: (VPN Users:ADGroup) [Get-ADGroupMember], ADException + FullyQualifiedErrorId : The operation completed successfully,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember
I also noticed that when going to the group in Active Directory Users and Computers, I receive a message:
Active Directory Domain Services
Some of the object names cannot be shown in their user-friendly form. This can happen if the object is from an external domain and that domain is not available to translate the object's name.
Is there any way I can get the members successfully exported, regardless of if a few names aren't formatted properly, etc...? Thanks in advance for the help!