Skip to content

Instantly share code, notes, and snippets.

@CosmosKey
Created February 27, 2018 20:29
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 CosmosKey/431d55a90cfab3090f0431e045c00310 to your computer and use it in GitHub Desktop.
Save CosmosKey/431d55a90cfab3090f0431e045c00310 to your computer and use it in GitHub Desktop.
$Name = "MSFT-Office 365 Enterprise E1"
$groupSearcher = [adsisearcher]"(samaccountname=$Name)"
$group = $groupSearcher.FindOne()
$memberSearch = [adsisearcher]::new($group.GetDirectoryEntry(),"(&(objectClass=user)(objectCategory=Person))",[string[]]'samaccountname','base')
$memberSearch.AttributeScopeQuery = "member";
foreach($member in $memberSearch.FindAll())
{
$member.Properties['samaccountname']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment