List Group Members in Active Directory

List Group Members in Active Directory

This script can be used to list group membership in Active Directory.

This script can be used to list group membership in Active Directory.  As you can see on the following screenshot, this script uses an input file called Glist.csv which contains all group names.  You will see the output on the screen as well as in theGroupDetails.csv file.
Reference: www.sivarajan.com
<#  
This script can be used to list group membership in Active Directory 
 
http://portal.sivarajan.com/2010/08/list-group-members-in-active.html 
 
www.sivarajan.com 
 
#>
 
$GFile = New-Item -type file -force "C:ScriptsGroupDetails.csv" 
Import-CSV "C:ScriptsGList.csv" | ForEach-Object { 
$GName = $_.GroupName 
$group = [ADSI] "LDAP://$GName" 
$group.cn 
$group.cn | Out-File $GFile -encoding ASCII -append 
    foreach ($member in $group.member) 
        { 
            $Uname = new-object directoryservices.directoryentry("LDAP://$member"
            $Uname.cn 
            $Uname.cn | Out-File $GFile -encoding ASCII -append 
        } 

 

Leave a Reply