The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Do you want to export or import AD members (users) from Active Directory groups? This guide teaches you different methods to perform this task.
Option 1: Manage AD Group Members with PowerShell
As I already hinted in my introduction, you can use PowerShell to either export or import users from an Active Directory group. Talking about importing or exporting users, PowerShell can import from a CSV file or export to a CSV file.
However, when it comes to a text file, although you can import group members from a text file, it is limited. So, in the second subsection of this section, I will only show you how to export group members to a text file.
1. Export AD Group Members to a Text or CSV File With PowerShell
Follow the steps below to export or import group members to a text or CSV file:
#1 Best Overall
- Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
- Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
- Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
- Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
- Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
- Decide the user’s properties you want to export. To get a list of all the properties of the users in an AD group, use the command below:
Get-ADGroupMember -Identity "Remote Writers"
The command returns the default properties of the members of the AD group. The AD group in my sample command has two members.

In this example, I’ll export the group members’ name, SamAccountName, and distinguishedName. Now, I will modify the previous command to return these values.
Get-ADGroupMember -Identity "Remote Writers" | Select-Object name, SamAccountName, distinguishedName
As expected, this command returns the properties I specified…
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

- Decide whether you want to use the default properties of the headers or customize them. The next important step to exporting members of an AD group is to decide whether you want to change the table headers or use the default values.
If you decide to use the default values, retain the last command (as shown below); then proceed to step 3.
Get-ADGroupMember -Identity "Remote Writers" | Select-Object name, SamAccountName, distinguishedName
However, if you decide to customize the result headers, use a command similar to the one below:
Rank #2
- MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
- SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
- ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
- ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
- HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³
Get-ADGroupMember -Identity "Remote Writers" | Select-Object @{Name="Full Name";Expression={$_.name}}, @{Name="UserName";Expression={$_.SamAccountName}}, distinguishedName
Now the command returns more user-friendly column names!.

- Finally, export the AD group members to a CSV file or text file with the following commands, respectively.
Get-ADGroupMember -Identity "Remote Writers" | Select-Object @{Name="Full Name";Expression={$_.name}}, @{Name="UserName";Expression={$_.SamAccountName}}, distinguishedName | Export-CSV "C:\report\Remote_Writers_Members.CSV" -NoTypeInformation
Get-ADGroupMember -Identity "Remote Writers" | Select-Object @{Name="Full Name";Expression={$_.name}}, @{Name="UserName";Expression={$_.SamAccountName}}, distinguishedName | Out-File "C:\report\Remote_Writers_Members.txt"
The two commands exports the AD group members to a CSV and text file respectively. In the screenshot below, I show the files explored and also the text file.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches
2. Import Users to Active Directory Groups From CSV with PowerShell
In the last sub-section, I showed you how to export members of an AD group to text or CSV file with PowerShell. In this sub-section, you’ll learn how to perform the opposite task – import Active Directory users from a CSV file as AD group members.
To perform this task, follow the steps below:
- Create a CSV file with the SamAccountName of the AD users. The CSV file will have the SamAccountNames of the users you want to add to the AD group.
You can use the command below to export the SamAccountNames of the users. In this example, I am exporting all users in the domain to a CSV file called All_AD_users.csv.
Get-ADUser -Filter "(Name -notlike 'guest') -and (Name -notlike 'administrator')" -SearchBase "DC=itechguides,DC=local" | Select-Object SamAccountName | Export-Csv C:\report\All_AD_users.csv -NoTypeInformation
- Import the users to the AD group using the command below. In this example, I am adding the AD users I exported in step 1 to the “Remote Writers” Active Directory group.
As shown in the screenshot below, the “Remote Writers” AD group does not have any members.
Rank #3
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.

To import and add all AD users in my CSV file to the “Remote Writers” Active Directory group, I’ll run the command below:
Import-Csv C:\report\All_AD_users.csv | ForEach-Object {Add-ADGroupMember -Identity "Remote Writers" -Members $_.SamAccountName}
After I run the command, the “Remote Writers” Active Directory group has all the users in the CSV file as members.

Option 2: Manage AD Group Members with DSQuery
In this section, you’ll learn how to export AD group members to a text file. Unfortunately, if you use the “dsquery group” command to export users to a CSV file, it does not create headers.
So, if you want to use the command prompt to export Active Directory group members, I recommend you export to a text file. Based on all the aforementioned, to export the members of the “Remote Writers” Active Directory group to a text file, I’ll run the command below:
dsquery group -name "Remote Writers" | dsget group -members > C:\report\All_AD_users_.txt
The result is a text file with the DN of all the users in the AD group.
Recommended Free Tools
Rank #4
- Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
- Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
- Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
- Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
- From Sandisk, a brand professional photographers trust to take on assignments.

Frequently Asked Questions
To export users from an Active Directory group, run the Get-ADGroupMember PowerShell command. For example, the command below exports all members of the “Remote Writers” AD group:
Get-ADGroupMember -Identity “Remote Writers” | Select-Object SamAccountName | Export-CSV c:\reports\remote_writers.CSV -NoTypeInformation
Then, I can import the exported users as members of another AD group with the command below:
Import-Csv c:\reports\remote_writers.CSV | ForEach-Object {Add-ADGroupMember -Identity “Remote Writers” -Members $_.SamAccountName}
There are so many objects you can export users from in AD. For example, you can export all users in the domain.
Alternatively, you can export users from a group or an OU. To export all users in your domain to a text file, run a command like the one below:
Get-ADUser -Filter “(Name -notlike ‘guest’) -and (Name -notlike ‘administrator’)” -SearchBase “DC=itechguides,DC=local” | Select-Object SamAccountName | Export-Csv C:\report\All_AD_users.csv -NoTypeInformation
Replace the value in the -SearchBase parameter with the DN of your domain. However, if you want to export all members of an OU, add the DN of the OU in the -SearchBase parameter.
Finally, to export AD users from a group, see question 1 above.
To export data from Active Directory to Excel:
i) Run the relevant PowerShell command to retrieve the data you need from Active Directory
For example, to get the SamAccountName of all AD users in the domain (excluding guest and administrator), run the command below:
Get-ADUser -Filter “(Name -notlike ‘guest’) -and (Name -notlike ‘administrator’)” -SearchBase “DC=itechguides,DC=local” | Select-Object SamAccountName
ii) Then, to export the result to CSV file, pipe the result of the above command to the Export-Csv command. Here is a sample command.
Get-ADUser -Filter “(Name -notlike ‘guest’) -and (Name -notlike ‘administrator’)” -SearchBase “DC=itechguides,DC=local” | Select-Object SamAccountName | Export-Csv C:\report\All_AD_users.csv -NoTypeInformation
Before you run this command, change the -SearchBase to the DN of your domain.
To create an Active Directory user from a CSV file, follow the steps below:
i) Use the Import-CSV command to fetch the users in the CSV file.
ii) Then, pipe the output of the Import-CSV command to a ForEach-Object command.
iii) Finally, within the ForEach-Object command, run the New-ADUser command and specify the entries from the CSV file.
Here is a sample command that creates new AD users from a CSV file that contains the users’ names and SamAccountNames.
Import-CSV [path to CSV file] | ForEach-Object {New-ADUser -Name $_.SamAccountName}
In this example, I assume that the user names of the users are in the SamAccountName column of the CSV file.
The fastest way to export users from Windows is to run the Get-LocalUser PowerShell command. If you run this command without any parameters, it displays all Windows users on the local computer on the PowerShell console.
However, to export the users to a text file, pipe the result of the Get-LocalUser to Out-File.
Get-LocalUser | Out-File [path to text file]
Alternatively, to export all local Windows users to a CSV file, run the command below:
Get-LocalUser | Export-CSV [path to text file] –NoTypeInformation
Best Value
- NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
- IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
- POCKET-SIZED – fits easily in pockets and small bags.
- SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
- 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.
Conclusion
One of the requested AD SysAdmins receives is producing user reports. Interestingly, one of the popular requests AD SysAdmins get is exporting members of an AD group.
The good news is that in this guide, I covered all the methods to complete this task.
Specifically, in the guide, I showed you how to perform this task with PowerShell. Not only that, but you also learned how to import Active Directory users to AD group members.
Then, the guide also covered how to export AD group members with Command Prompt.
I hope I made your day with this guide! If I did, click on “Yes” beside the “Was this page helpful” question below.
You may also express your thoughts and opinions by using the “Leave a Comment” form at the bottom of this page.
Finally, to keep improving your Active Directory skills, read more guides on our Active Directory Guides page.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

