Export Members Of Ad Group


You can import or export group members with PowerShell. However, you can only export group members with Command Prompt. So, in the first section of this guide, you’ll learn how to export or import Active Directory group members with Windows PowerShell. Then, in section two, I” teach you how to export members of an AD group with the dsquery command prompt command.

Export Or Import AD (Active Directory) 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.

How To 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: 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. As expected, this command returns the properties I specified… If you decide to use the default values, retain the last command (as shown below); then proceed to step 3. However, if you decide to customize the result headers, use a command similar to the one below: Now the command returns more user-friendly column names!. 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.

How To 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: 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. As shown in the screenshot below, the “Remote Writers” AD group does not have any members. To import and add all AD users in my CSV file to the “Remote Writers” Active Directory group, I’ll run the command below: After I run the command, the “Remote Writers” Active Directory group has all the users in the CSV file as members.

Export AD (Active Directory) Group Members With The “DSQuery Group” Command

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: The result is a text file with the DN of all the users in the AD group.

My Final Thoughts About Exporting Members Of An AD Group

One of the requested AD SysAdmins receive 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, kindly spare me two minutes to share your thoughts and feedback. To give your feedback about this article and its content, reply to this article’s topic at Itechguides Community Forum. Finally, to keep improving your Active Directory skills, read more guides on our Active Directory Guides page.

References And Furter Reading