Saturday, February 1, 2014

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

2 comments:

  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!

    ReplyDelete
  2. don't use indirect parameter, it should do the job.

    ReplyDelete