Get-ADGroupMember

Glenn Maxwell 12,876 Reputation points
2022-06-19T06:56:55.567+00:00

Hi All

i have an AD group(TEST_group1) which has 5000 plus users. i want to export all the users of this AD group to a csv file. will the below syntax help me fetch the information. i want to fetch DisplayName, UPN and SamAccountName

Get-ADGroupMember -Identity $group -resultpagesize 2147483647 |  
    Select-Object -Property @{n="Username";e={$_.Name}}, DisplayName,UserPrincipalName,samaccoutname  
        @{n="TEST_group1";e={$group}} |  
    Export-Csv C:\temp\TEST_group1_members.csv -NoTypeInformation -Append  
  
Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. Limitless Technology 39,926 Reputation points
    2022-06-21T07:39:22.973+00:00

    Hi there,

    Run PowerShell as administrator. Change the path to the scripts folder. Run the PowerShell script to export AD group members to CSV file. Wait till it completes.

    PS C:\> cd c:\scripts
    PS C:\scripts> .\Export-ADGroupMembers.ps1


    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. T. Kujala 8,766 Reputation points
    2022-06-19T08:32:18.533+00:00

    Hi @Glenn Maxwell ,

    How about the following command?

    Get-AdGroupMember -Identity 'TEST_group1' | Get-AdUser -Properties * | Select DisplayName,UserPrincipalName,samaccountname | Export-csv -Path c:\temp\TEST_group1_members.csv -NoTypeInformation  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.