PowerShell: Export Active Directory Group Members

One common request I see is getting a list of users that belong to an Active Directory security group. This is requested for various reasons such as, supervisor wants to know who has access to a folder, an auditor wants a list of users, a 3rd party program or cloud service needs to import a list of users from a CSV file.

The problem is…

The built in Active Directory users and Computer tool has no option to export members from a group.

To accomplish this we can use PowerShell.

In this tutorial, I will walk through the steps for exporting group members to a CSV file.

Let’s get started.

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

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 following 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

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

RELATED: Tutorial on how to install PowerShell modules

Step 2: Find AD Group

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 command to list all Active Directory groups.

Get-ADGroup -filter * | sort name | select name

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 members

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

Get-ADGroupMember -identity "HR Full"

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

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

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

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.

Pretty easy right?

Method 2: Group Membership Report Tool

This method requires no PowerShell. This GUI tool is super easy to use and has built in support to export all groups and group members. Plus you can quickly find all nested groups!

Step 1: Download and Install the AD Pro Toolkit

Click here to download a free trial

Step 2: Open AD Pro Toolkit and click on Group Membership Report

Step 3: Choose Paths and click run

  • Entire Domain = Gets all groups and group members in the entire domain
  • Select OU or Group = This lets you select one or multiple OUs or groups.

For this example, I’m going to select entire domain.

Now click the run button and you will get a report of groups and users in each group.

All domain groups and group members

Step 4: Export to CSV

At this point, you can export the report to a CSV file by clicking the export button and select “Export All Rows”. By default, there are over 30 attributes included in the export. If you want to change what attributes are exported then click the change Columns button to add or remove them.

Export Groups to CSV

Step 5: Filter Results and find nested groups (optional)

If you need to filter the report such as finding nested groups or display certain group types (security or distribution) then you can do that right in the tool. The tool comes with a powerful search and filter system. In this example, I will find all nested groups.

You can right click on any column to access the filter options. To find all nested groups select “Filter Editor”

Set the filter to the screenshot below and click apply.

Now the report will be filtered to show all nested groups.

In the above screenshot, the first column is the source group and then the group column is the group it’s a member of. So Domain Users is a member of the Legal_Folders group. The next one down Accounting_Printers is a member of the Accounting_Local group.

This filtered report can now be exported to CSV.

The Group Membership Report Tool is a huge time saver and makes it so easy to report and export group membership.

Download Your Free Trial Here

Recommended Tool: Permissions Analyzer for Active Directory

This FREE tool lets you get instant visibility into user and group permissions. Quickly check user or group permissions for files, network, and folder shares.

Analyze user permissions based on an individual user or group membership.

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

  1. 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

    • 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.

  2. 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?

  3. 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.

  4. 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.

  5. 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

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

  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.

    • 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 ?

  8. Hi Robert,

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

  9. 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.

  10. 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.

  11. 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”

  12. 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.

  13. Hi Robert, bit late to the party here. I am doing something similar but I wanted to be able to export only names that do not match part of a string to the CSV e.g names that do not match “admin*”. I can manipulate the CSV afterwards but would be great if I could do it as part of PS.

  14. Hi could you point me in the right direction? Any help would be appreciated. At step 3 I’m running into the following error….

    Get-AdGroupMember : An unspecified error has occurred
    At line:1 char:1
    + Get-AdGroupMember -identity GROUP-TESTA
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: GROUP-TESTA:ADGroup) [Get-ADGroupMember], ADException
    + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember

    • Does the group have members from another domain? This command only works if the group members are all from the same domain.

  15. Hi Robert, how would I get a listing of all members in an AD group that has members from 2 different domains (universal group). Is this possible? Thanks.

  16. Thanks ,Its very useful for audit purpose, I have created around 24 .CSV file. How do I can add all in one excel in different tabs in sing excel.

    Thanks again
    Vaibhav Joshi

  17. Hi Robert, thank you for sharing all these helpful commands and PS-Scripts.

    I am trying to create a script that will export all users with their manager name to a csv file. (i got this part done already), I used: get-aduser -Filter * -Properties Manager | Select-Object Name,sAMAccountName,Manager | export-csv C:\temp\UsersManagersExample.csv -notypeinformation.

    But also that shows all the membership groups for each user. I am not sure what is the best way to achieve this. Can you help? I am quite sure that there is a way to get this done using powershell.

    So I am trying to get a list of all managers and their reporties plus the membership assigned to each user.

    Thank you in advance!
    Best Regards,


  18. Hi
    How do I get groups within a nested group please? So I have a parent group, then within that, I have nested groups. I wanted those nested groups (not users)



Leave a Reply to Robert Allen Cancel reply