Script to query all users in the domain and find out which Global Groups they belong to

Script to query all users in the domain and find out which Global Groups they belong to or query all users and find out if the belong to any of the groups in a specific OU.
scfcuAsked:
Who is Participating?
 
SubsunCommented:
If you have windows 2008 R2 Domain controller or above then you can try...
Import-Module Activedirectory
Get-ADUser -Filter * -Properties DisplayName,memberof | % {
 $Name = $_.DisplayName
 $_.memberof | Get-ADGroup | ?{$_.GroupScope -eq "Global"} | Select @{N="User";E={$Name}},Name
} | Export-Csv C:\temp\report.csv -nti

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.