Skip to content

Instantly share code, notes, and snippets.

@egde
Created November 14, 2018 13:47
Show Gist options
  • Save egde/4319a8fd9ad92e872569e2d5a8f795a7 to your computer and use it in GitHub Desktop.
Save egde/4319a8fd9ad92e872569e2d5a8f795a7 to your computer and use it in GitHub Desktop.
# Define LDAP search root, the Global catalog of the domain
$sLDAPSearchRoot="LDAP://YOUR.CORP.ORG"
# The Groupname to looking for
$sGroupName="AD_GROUPNAME"
# The query string
$sSearchStr ="(&(objectCategory=group)(name="+$sGroupName+"))"
# Get the search object
$oSearch=New-Object directoryservices.DirectorySearcher($oADRoot,$sSearchStr)
# Looking for the group
$oFindResult=$oSearch.FindAll()
$oGroup=New-Object System.DirectoryServices.DirectoryEntry($oFindResult.Path)
$oGroup.member | Out-GridView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment