Updated Script - http://portal.sivarajan.com/2011/10/search-ad-collect-local-admin-group.html
| Script #1 |
This script can be used to list group membership in Active Directory. Input – Group DN
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 the GroupDetails.csv file.
You can download the script from the following locations. Rename the file to .PS1
http://www.sivarajan.com/scripts/Group_Members.txt
http://gallery.technet.microsoft.com/scriptcenter/dcc9432e-d541-4be2-a39c-637c8d4c9fd0
| Script #2 |
Modified Script – This script will prompt you for the Group distinguishedName (DN).
| Script #3 |
$OutPutFile = New-Item -type file -force "D:\Scripts\GroupDetails.csv"
#update filter based on your requirement
# 2 Global distribution group
# 4 Domain local distribution group
# 8 Universal distribution group
# -2147483646 Global security group
# -2147483644 Domain local security group
# -2147483640 Universal security group
$ObjFilter = "(&(objectCategory=Group)(|(groupType=2)(groupType=4)(groupType=8)))"
$objSearch = New-Object System.DirectoryServices.DirectorySearcher
$objSearch.SearchRoot = "LDAP://OU=DLs,DC=Sivarajan,DC=com"
$objSearch.PageSize = 10000
$objSearch.Filter = $ObjFilter
$Results = $objSearch.FindAll()
foreach ($Result in $Results){
$Item = $Result.Properties
Write-host $Item.cn
$Item.cn | Out-File $OutPutFile -encoding ASCII -append
foreach ($Member in $Item.member) {
Write-host "$Member"
$Member | Out-File $OutPutFile -encoding ASCII -append
}
}
| Script #4 |
Nested Group Report - This script will search AD for all security groups and generate a nested group details. Output will contain only Groups.
Script
Clear
$AllGroupNames = Get-ADGroup -Filter {(GroupCategory -eq 'security')} #-SearchBase 'DC=domain1,DC=com'
#Gnames - contins all Security group details
foreach ($GNamet in $AllGroupNames)
{
Write-Host "Parent Group Name -" $GNamet.Name, $GNamet.GroupScope
#GNamet contins all Group properties
$Gname = $GNamet.Name
#$Gname contians only group names
$AllGmembers = Get-ADGroupMember -identity $Gname
#$AllGmembers - memeber details from each security group
foreach ($GMemebr in $AllGmembers) #Loop for verifying each member type
{
If ($GMemebr.objectClass -eq "Group") #verifying each member type.
{
$ChildGroupProp = Get-ADGroup -Identity $GMemebr
Write-Host "Child Group Member(s)-" $GMemebr.name, $ChildGroupProp.GroupScope -ForegroundColor Green
}
}}
Output
Output will contain parent and child group and group type.








![[image%255B3%255D.png]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA0r1n8sdY44gB3U20rlPa4fjjdxUH8WAvyqZp21VyM0YEkuDYvpHk45I3HFeHCjJhSz3L-TD4NXTsHY6gqnJY-LEt0l6c1Td05y3jFMh_fWgIx3MT1Pfr6qObImxHekP3hrN29sUVx4c/s1600/image%25255B3%25255D.png)

