Powershell AD Users in group sorted by group

Greetings Experts,
I have a huge Active Directory structure with hundreds of groups.  Recently management has asked for a list to be presented quarterly, to ensure each user is a member of the proper groups, since everything we have secured is via group, obviously.  The list will be distributed to many non-techies, to confirm each of their own departments are proper.

I have found some powershell scripts, however none of them provide the output I am looking for exactly - this is the current PS script iteration I am using:

Import-Module ActiveDirectory

$Groups = (Get-AdGroup -filter * | Where {$_.name -like "**"} | select name -expandproperty name)

$Table = @()

$Record = @{
"Group Name" = ""
"Name" = ""

Foreach ($Group in $Groups)

$Arrayofmembers = Get-ADGroupMember -identity $Group -recursive | select name

foreach ($Member in $Arrayofmembers)
$Record."Group Name" = $Group
$Record."Name" = $Member.name
$objRecord = New-Object PSObject -property $Record
$Table += $objrecord



$Table | export-csv "C:\new\it4_SecurityGroups.csv" -NoTypeInformation

My issue is the output creates a not-so-easy-to-read CSV - that I would have to format before sending to the management teams, I am looking for something more like the second attachment.  Is there any way to format the CSV to come across closer to this preferred format?  I know there has to be a fantastic time saving way to do this!

Thanks in advance!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well, that format is no longer a .CSV, but here's something like your example.
Import-Module ActiveDirectory

$Groups = Get-AdGroup -filter * | select -ExpandProperty name | Sort

@(Foreach ($Group in $Groups)
    Write-Output "$Group"
    Get-ADGroupMember -identity $Group -Recursive | select -ExpandProperty name | Sort
    Write-Output ""
}) | Out-File SecurityGroups.txt -Encoding ascii

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tfreyderAuthor Commented:
I love you 100 times over.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.