Skip to content

Instantly share code, notes, and snippets.

@happiness801
Created February 4, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save happiness801/5ad735877bc4e621bc61e84124c5fc89 to your computer and use it in GitHub Desktop.
Save happiness801/5ad735877bc4e621bc61e84124c5fc89 to your computer and use it in GitHub Desktop.
Gets list of groups that a user belongs to
param([String]$requestuser=$env:username)
(
New-Object System.DirectoryServices.DirectorySearcher(
"(&(objectCategory=User)(samAccountName=$requestuser))"
)
).FindOne().GetDirectoryEntry().memberOf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment