How to export member of group in active directory
How to export member of group in active directory
In this article I will discuss how I use the Get-ADGroupMember cmdlet to get a list of Active Directory Group members and dump it to a csv file. You will need to have the Active Directory Module for PowerShell installed to use this cmdlet. Once you have the Active Directory Module for PowerShell installed you can open PowerShell as Administrator and type the following to import the module (module will be imported automatically when executing the “Get-ADGroupMember” cmdlet in PowerShell 3.0)
Step 1: “Import-Module ActiveDirectory”
After you import the AD module type the following changing the identity to reflect your group name and the path to export group members to a csv file in that directory:
Step 2: Get-ADGroupMember -identity “Name of Group” | select name | Export-csv -path C:\Output\Groupmembers.csv -NoTypeInformation
You should now have a list of members by display name in a csv file located at C:\Output\Groupmembers.csv. If you wanted to list out the users by samaccountname you could just change out “name” after the select statement with “samaccountname”.
Now lets say you are using nested groups. You will notice that your list will reflect the nested group name and no the members of the nested group. All you need to do in this case is add the -recursive parameter to enumerate all the nested group members and add them to the list. This would look as follows:
Step 3 : Get-ADGroupMember -identity “Name of Group” -recursive | select name | Export-csv -path C:\Output\Groupmembers.csv -NoTypeInformation
I hope this helps. If you have any questions or feedback please leave a comment.
0 comments
Please leave your comments...... Thanks