Skip to content

Instantly share code, notes, and snippets.

@franc01s
Created May 10, 2021 11:53
Show Gist options
  • Select an option

  • Save franc01s/da2475ef986267ea25958bd2a37c50e8 to your computer and use it in GitHub Desktop.

Select an option

Save franc01s/da2475ef986267ea25958bd2a37c50e8 to your computer and use it in GitHub Desktop.
$ADGRP="CN=Domain Admins,CN=Users,DC=itslab,DC=local"
$memberof = (New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf
if ($memberof.Contains($ADGRP)) {
write("Catch")
}
else{
write("NoCatch")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment