Since I started working with and learning Powershell, I try to find solution of complicated tasks which seems to be simple when we put in one Sentence.
Well, one way is to double click a group and check the members tab and enter in Excel rows and columns. If I have nothing else to do and I love clicking mouse buttons then I guess that will be a nice time killer job. or else find a 3rd party software a freeware or shareware with limitations that does not really most of the time gives what I need.
Fortunately my favorite is PowerShell !.,
$Report = @()
$GroupCollection = Get-ADGroup -Filter * | select Name,MemberOf,ObjectClass,SAMAccountNameForeach($Group in $GroupCollection){
$MemberGroup = Get-ADGroupMember -Identity $Group.SAMAccountName | where{$_.ObjectClass -eq ‘group’}
$MemberGroups = ($MemberGroup.Name) -join “`r`n”
if($MemberGroups -ne “”){
$Out = New-Object PSObject
$Out | Add-Member -MemberType noteproperty -Name ‘Group Name’ -Value $Group.Name
$Out | Add-Member -MemberType noteproperty -Name ‘Member Groups’ -Value $MemberGroups$Report += $Out
}
}
$Report | Sort-Object Name | FT -AutoSize
$Report | Sort-Object Name | Export-Csv -Path ‘C:\Group-MemberGroups-Report.csv’ -NoTypeInformation
Hope this helps.
Don’t forget to Wrap Text the Member Groups column.
this doesn’t seem to return the nested groups when I used it. It only returned 1 group when there were over 200 groups. Any ideas?
Hi Chris,
May be you did not “Wrap Text” the “Member Groups” Column.