export members or users from active directory group using Powershell to csv

If you are a Windows system administrator or working on a Windows Active Directory then you often need to export the active directory group members.

For example, if you want to find a list of users who are working in the Administrators group, we can export all users in that group using the commands & scripts below using PowerShell.

You can not do this using the Active Directory users and Computer GUI tool as it has no option to export members from a group.

You can use the free Admin Bundle for Active Directory, a trio of free utilities from SolarWinds to help you manage Active Directory users. You can remove inactive accounts and computers, and even import new users.

In this tutorial, we will show you how to export the Active Directory Group Members using PowerShell.

Getting Started

Before starting, make sure the PowerShell Active Directory module installed in your system.

You can run the following command to list the installed module in your system:

Get-Module -Listavailable

In the following screen, you should see that the PowerShell module is already installed in your system.

Get-Module -Listavailable

If not installed, you can install it with the following command:

Add-WindowsFeature RSAT-AD-PowerShell

You can also install the PowerShell module using the Server Manager Gui tool by following the below steps:

Install Active Directory Module for Powershell:

1. Open Server Manager

2. Click on the Add Roles and Features.

3. Click Next until you reach Features.

4. Click on the Remote Server Administration Tools => Role Administration Tools => AD DS and AD LDS Tools then Enable Active Directory module for Windows PowerShell.

5. Click on the Install button to install the PowerShell module.

Find the Active Directory Group Name

Next, you will need to list the available groups in the Active Directory.

So you can easily identify your desired group name and exports their members using Powershell as well.

Run the following command to list all Active Directory groups in your system.

get-adgroup -filter * | sort name | select Name

You should see the complete group list in the following screen:

get-adgroup -filter * | sort name | select Name

List Members of Specific Group

At this point, you have a list of all groups in your Active Directory as seen in the image above.

Next, you can use the following syntax to list the members of a specific group:

Get-AdGroupMember -identity "Group Name"

For example, to list all the members of the Administrators group, run the following command:

Get-AdGroupMember -identity "Administrators"

You should see all members of this group with more details in the following screenshot below:

list the members of a specific group using powershell

You can also filter the above command to list only the member name as shown below:

Get-AdGroupMember -identity "Administrators" | select name

You should see the following screen:

Get-AdGroupMember -identity "Administrators" | select name

Export Group Members to CSV File

At this point, you have a complete list of members of the Administrators group.

Now we can export this list to a CSV file named members.csv by running the following command:

Get-AdGroupMember -identity "Administrators" | select name | Export-csv -path C:\members.csv -NoTypeInformation

You can verify the generated CSV file as shown below:

export AD group members to CSV file


In the above tutorial, we learned how to export Active Directory group members to CSV file using the PowerShell.

PowerShell is a powerful and very useful tool that helps you to perform the Active Directory related task within minutes without the need of additional software or paid tools! If you do need help with some tools, the free Admin Bundle for Active Directory from SolarWinds is a good place to start.

Questions & Comments are Welcome, please post them below!

Comments & Discussion:

  1. I have groups with dollar signs in the name and this doesn’t work for those. I even tried the back tick to escape and add a dollar sign to the string and it fails.

Comments are closed.