PowerShell: Export Active Directory Group Members

In this guide, you will learn how to export AD group members to csv. I will show you how to get a list of groups and members with PowerShell and the AD Pro Toolkit.

In this article:

Option 1. Export Group Members to CSV using the AD Pro Toolkit

The AD Pro Toolkit includes multiple AD group member reports that can be export to CSV, Excel or PDF File.

You can Download a Free Trial and try these reports in your own domain.

Step 1. Click on “Group Reports” and select “Group Members Report”.

ad group members report

Step 2. Click “Browse” to select a specific group or OU. By default, the tool will get all groups and members.

select ad group or ou

Step 3. Click the “Columns” button if you want to add or remove user fields.

Step 4. Click “Run” to generate a list of the group members.

Step 5. Click the “Export” button” to export the list to csv.

export group members to csv

You can also get a list of groups a user is a member of by running the “User Groups Report”.

user ad groups report

Nested Groups and Members

To get a list of nested groups and members click the “Nested Groups report. This will list all groups that are members of another group. If the parent group has members, you can expand it to see the list.

nested group and members report

List only Security Group Members

With the toolkit, you can easily filter on any of the columns. In this example, I’ll filter on the group type to list only security groups and members.

Click on the groupType column and select Security.

get security groups

Now the tool will only display security groups and the group members.

list of security groups

The toolkit also includes the following group member reports.

  • Nested groups
  • Nested groups tree view
  • Groups with no members
  • All security groups
  • All distribution groups
  • Recently modified groups
  • Recently created groups

Option 2. Export Group members to CSV with PowerShell

In this example, I’ll use PowerShell to get a list of users in AD groups and export them to CSV.

Step 1: Load the Active Directory Module

To connect and query an AD group with PowerShell the Active Directory module needs to be loaded.

The Active Directory module can be installed with the following methods:

  • RSAT tools installed
  • Windows Server 2008 R2 and above with the AD DS or AD LDS server roles

You can run the following command to see if you have installed.

Get-Module -ListAvailable
powershell module

As you can see, I don’t have the module installed.

If you already have the module loaded then jump to step 2, if not then follow these instructions.

To get the Active Directory module installed on my Windows 10 PC, I will need to download and install the RSAT tools.

With the RSAT tools installed, I run the Get-Module -ListAvailable command again

check powershell ad module

Now I have the module installed, let’s move on to step 2.

RELATED: Tutorial on how to install PowerShell modules

Step 2: Use Get-ADGroup to find the group name

If you already know the name of the group, then skip to step 3.

If you’re not sure what the group name is, you can issue the following PowerShell command to list all Active Directory groups.

Get-ADGroup -filter * | sort name | select name
get-adgroup powershell command list groups

Above, is a screenshot of some of the groups listed in my domain. I had an HR group but wasn’t sure of its complete name, I can see it’s HR full. I’ll use that group in step 3 to list out the members.

Step 3: Use Get-AdGroupMember to list group members

The following PowerShell command will list all members of my HR Full group.

Get-ADGroupMember -identity "HR Full"
get-adgroupmember powershell command

You can see the above command provides more details on the group members than I need.

We can filter out the results and just get the member name with this command.

Get-ADGroupMember -identity "HR Full" | select name
list only group members with powershell

Perfect, now I just need to export this to CSV.

Related: How to export all Users from Active Directory

Step 4: Export group members to CSV file with PowerShell

The last step is to export the results to a CSV file.

This is done by adding Export-csv to our above commands. The full command looks like this.

Get-ADGroupMember -identity "HR Full" | select name | Export-csv -path c:\it\filename.csv -Notypeinformation

Now I have a CSV file of all the members from the HR Full Active Directory group.

csv example of ad group members

Pretty easy right?

Schedule Automatic Group Member Reports

With the AD Pro Toolkit, you can schedule email reports of group members. This will email you a list of groups and members on a daily, weekly or monthly basis.

  1. Click on “Scheduler”.
  2. Click “Add”.
  3. Select “Reports” and give the task a name.
  4. Choose a schedule frequency and time.
  5. Select “Groups -> General” and then select “group members”.
  6. Select an OU or specific groups.
  7. For the Ouput options select “Email CSV” or “Save CSV”.

AD Pro Toolkit (19 Tools in 1) Easy to Use GUI Tools for Active Directory

Download Free Trial

129 thoughts on “PowerShell: Export Active Directory Group Members”

  1. Short and sweet, thanks!

    However, FOR NOOBS LIEK ME, in Step 4, it’s confusing that after “Export-csv -path” you got new empty line and then “C:OutputGroupmembers.csv -NoTypeInformation” which doesn’t work.

    Obviously, it should be all together and have a backslash “\” to be able to export to the C-drive root IF it works by other policies. IMO would be better to point the output file to the “C:\temp\filename.csv” which is probably more accessible.

  2. This is one of the best explanations that I could find – Thanks!

    Would you know how to deal with a group with a large amount of members? My results are “The size limit for this request was exceeded”

  3. Hi Robert,
    Thank you for your post. How do I export group members from a specific domain. When I ran the Get-AdGroupMember command, it gets it from a specific domain.

  4. Hi Robert,
    Thank you for your post. How do I export group members from a specific domain. When I ran the Get-AdGroupMember command, it gets it from a different domain.

  5. Hi Robert,

    The Commands are working, But I need to export the members from Multiple Groups. Is there any commands for that ?

  6. This is Awesome.. Helped me a lot.

    I have two quick questions:
    1. How can I see Group name and Member name as output?
    2. How can I choose multiple groups?

    Thanks in advance.

    • Good day ?, how to get 8000 members list from 1 AD group using cmdlet Get-AdGroupMember and export it to cvs file ?

      Thanks a lot and have a nice day ?

  7. This is extremely handy especially for someone who is still learning Powershell. I wondered if this script could be configured to run in one domain and pull data from a group in another? You would have to be able to add ID and password from the other domain for it to work.

  8. It was really useful. Thank you. Is there a possibility to add First name and Last name in the output from the AD group

  9. very interesting/handy…
    I have a range of AD groups I want to list (eg all AD groups starting g_abcCouncil) how would I modify the filter command ?

    (I tried -filter g_abcCouncil* but got a parsing error, not supported)

    • You want to list just the groups and sort them or the groups and members? This would get all groups and sort them get-adgroup -filter* | sort

  10. Thank you so much for this! As a beginner, I wanted a quick way of getting the list of users from a specific group. I searched it for weeks and finally found this post! . With these commands, lot of hours will be saved.

  11. Hello Robert,

    How do i get the list of member from group A, group B, i.e group B is not a sub group of group A
    and i don’t want to right separate command like this Get-AdGroupMember -identity “Group A” | select name.

    I Tried Get-AdGroupMember -identity “Group A” “Group B” | select name and i got error :/

    Thanks for the help.

  12. Hello, Thank you for the post. But I get an error on Step 2: “get-adgroup : Unable to find a default server with Active Directory Web Services running.”

    • Yulia,

      The Powershell Active Directory module uses AD Web services to manage and administer Active Directory. You will need to make sure your server is running AD web services. What version of server are you running?

  13. I’m looking for a similar script to export to csv groups and members within groups:

    • Hi Richard,

      Just add -Recursive at the end to include members of child groups


      Get-AdGroupMember -identity HR Full -Recursive

      • Hi Robert,

        What if i have to get entire (All) groups in one excel?

        instead of a specific group, I need to have all my groups with their current users in it.

          • You could try something like this:

            $groups = get-adgroup -filter *

            foreach ($group in $groups) {
            $naam = $group.name
            $members = Get-ADGroupMember -identity $group
            write-host “Group: $naam”
            write-host “————————————-”
            foreach ($member in $members) {
            $memnaam = $member.samaccountname
            write-host “$memnaam”

        • Here’s how I got it to work:

          $date=get-Date -Format “yyyyMMdd”
          $groupList=Get-ADGroup -filter * | sort name | select name
          write-Output “””ADGroupName””,””ADUserSAMAccountName””” | Out-File .\ADGroupMembership-$date.csv
          foreach ($group in $groupList) {
          $memberList=Get-ADGroupMember -Identity $group.name | Select SamAccountName
          foreach ($member in $memberList) {
          write-Output “””$($group.Name)””,””$($member.SamAccountName)””” | Out-File .\ADGroupMembership-$date.csv -Append

      • Hi,

        I have problem with the bellow command:
        Get-ADGroupMember -identity β€œBss_nbe” | select name
        it’s showing only domain users group members, but she is not listing contact members ( insite of the group we have users & contacts, this command show only users )

    • I am trying to extract a list of users given a security group. I know that this is easily accomplished using:

      Get-AdGroupMember -identity “security group name” | select name | Export-csv -path C:\members.csv -NoTypeInformation

      But, what I am trying to do is perform this action given a .csv file of security groups. For example, I have 36 security groups that I would like to query for their respective members. Rather than run the above line 36 times in a row by manually inputing each security group, I would like to say: “Here, take this .csv file, iterate through it one by one and return the members of each group you see, then export all members sorted by each group when you reach the end of the file.

      Any ideas as to how to do this? I’ve tried using a foreach loop but I don’t think you can pass an array to the -identity parameter.

      • Was the script ever confirmed for this? I have around 50 security groups and want to export all the data into 1 CSV file rather than editing the command 50 times per security group.



Leave a Comment