Created
July 17, 2015 04:26
-
-
Save aaronpmiller/28bee4f94974f291d287 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-ADNestedMemberOf ($userName) { | |
# For a specified user get the groups it is a member of recursively. | |
$targetUser = Get-ADUser $userName | |
$results = Get-ADGroup -Filter {member -RecursiveMatch $targetUser.DistinguishedName} | |
return $results | |
} | |
Function Test-ADIsMember ($objectDN, $groupDN) { | |
# params require full DistinguishedName | |
# Generalized for any ADObject and the return is the not null test. This Will produce the same errors as the standard IsMember if either object doesn't exist | |
(Get-ADObject -Filter {memberOf -RecursiveMatch $groupDN} -SearchBase $objectDN -SearchScope Base) -ne $null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment