Using PowerShell to export Active Directory Group Members to a CSV File
Hi all,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)
“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:
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:
Get-ADGroupMember -identity “Name of Group” -recursive | select name | Export-csv -path C:\Output\Groupmembers.csv -NoTypeInformation
1 comment:
Need a competent hacker, i would be kind enough to let you know about the one who is currently working on a project of mine. Finally, after so many trials with different people.
WEBSITE chief-exec.wixsite.com/cryptech
MAIL: CHIEF-EXEC@MANAGEMENTPORTAL.BIZ
Tel: +1 424 264 0575
Post a Comment