This was very interest concept that i worked on for a project. Nested group checker basically will identify the AD groups that have nested groups and will standard groups.
Hope the below script helps.
$MilanCTXGroups = Get-ADGroup -Filter {samaccountname -like "group name"} -Properties samaccountname | select name
$nestedGroups = @()
$notnestedGroups = @()
foreach($group in $MilanCTXGroups){
$check = Get-ADGroupMember -Identity $group.name | select name,objectclass
foreach($line in $check){
if($line.objectclass.Contains("group")){
$nestedGroups += $group.name + " is nested into : " + $line.name
}
}
$notnestedGroups += "Not nested : " + $group.name
}
$nestedGroups
