Skip to content

Instantly share code, notes, and snippets.

@tom-henderson
Created August 24, 2017 03:55
Show Gist options
  • Save tom-henderson/8473af7fc585330128f09cd690d2d4c1 to your computer and use it in GitHub Desktop.
Save tom-henderson/8473af7fc585330128f09cd690d2d4c1 to your computer and use it in GitHub Desktop.
Get computer's group membership without using the AD module
$searcher = [adsisearcher]"(&(objectCategory=computer)(cn=$env:COMPUTERNAME))"
$searcher.FindOne().Properties.memberof -replace '^CN=([^,]+).+$','$1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment