Export AD group members – nested / recursive using Quest input via text file

Hi Readers,

http://gallery.technet.microsoft.com/scriptcenter/Export-AD-group-members-c647cfee (download link)

This is extension of below script & have been modified because of community user request.

http://gallery.technet.microsoft.com/scriptcenter/Export-AD-group-members-257002b5

Difference is that this one takes input via text file & can handle multiple group at ones.

Create a text file with group names, like I have created (in the same folder)

When you run batch file it will ask you for name of text file you created, just enter that.

Now you will get groupmembers in csv files as shown above.

download Quest Management Shell (its a free shell) –> http://www.quest.com/powershell/activeroles-server.aspx

##################################################################################  
#       Author: Vikas Sukhija  
#       Date: 06/31/2013  
#       Description: Extract group members recursevely  
#       Modified: 01/30/2014 
#       Modification: Take input from text file & report members(requested  
#       by MS community user) 
###################################################################################  

Param( 
     $path 
    ) 

$path = read-host "Please enter text file that contains group name" 
if($path -eq $null) 
{ 
Write-host "Please enter text file that contains group name" 
} 
else 
{ 
$import = get-content $path 

# Add Quest Shell... 

If ((Get-PSSnapin | where {$_.Name -match "Quest.ActiveRoles"}) -eq $null) 
{ 
    Add-PSSnapin Quest.ActiveRoles.ADManagement 
} 

$import | foreach-object { 

$Group = $_ 

$members = Get-QADGroupMember $Group -Indirect |  select Name, Type | Export-Csv .\$Group.csv 

} 
} 

###################################################################################

Regards

Sukhija Vikas

Advertisements

2 thoughts on “Export AD group members – nested / recursive using Quest input via text file

  1. Thank you for the script. How could the script be modified if I didn’t want it to pull members of any nested groups? For example, I have AD group “Test” and nested within this group I also have AD group “New.” I would want the results of the script to only show membership to the “Test” group but show that the “New” AD group is nested within but not include members of the “New” group in the results. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s