Categories
Windows Server 2003

Powershell : Export Active Directory Group Members

Powershell : Export Active Directory Group Members

First you will need to obtain the ‘ActiveRoles Management Shell for Active Directory’ from the following link: http://www.quest.com/powershell/activeroles-server.aspx

Next save the following code into a new ‘.ps1’ script file:

$data = @()
foreach ($grp in Get-QADGroup -SearchRoot “internal.local/UK” | select-object Name,DN ) {$data += get-qadgroupmember -identity $grp.DN | select @{n=”GroupName”;e={$grp.Name}},@{n=”GroupDN”;e={$grp.DN}},Name,@{n=”DistinguishedName”;e={$_.DN}},type}

$data | sort-object “GroupName” | export-csv C:\UK_GroupExport.csv

Modify the search root so that it reflects the domain name/OU you wish to enumerate groups and group members from. This should be in canonical form, for example “my.domain/myOU”.

On execution, this script will create a new csv file containing groups and all members, including nested groups.

Leave a Reply

Your email address will not be published. Required fields are marked *