Sunday, February 9, 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 

} 
} 

###################################################################################
follow me:-  http://msexchange.me
Regards
Sukhija Vikas

No comments:

Post a Comment