Skip to content

Instantly share code, notes, and snippets.

@cchitsiang
Created October 18, 2013 08:04
Show Gist options
  • Save cchitsiang/7038075 to your computer and use it in GitHub Desktop.
Save cchitsiang/7038075 to your computer and use it in GitHub Desktop.
Get Group Membership of Particular AD User
$ID = read-host "Enter the user's ID you wish to scan"
$FQDN = "cn=block_cloning,dc=yourdomain,dc=com" #full FQDN of the block_cloning group
Get-ADUser -Identity $ID -Properties memberOf | % {$_.memberOf} | % {Get-ADGroup $_ -Properties *} `
| select name, mail, GroupCategory, GroupScope,@{Label="Block_Cloning";Expression={
If ($_.MemberOf -contains $FQDN)
{ "Yes"
}
Else
{ "No"
}}} | Sort mail, name | Export-CSV c:\pathofexport.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment