06 July 2012

Test AD Group Membership

$Group = [ADSI]"LDAP://CN=Group Name,OU=Groups,DC=office,DC=net"
$User= [ADSI]"LDAP://CN=User Name,OU=Users,DC=office,DC=net"

If ($Group.IsMember($user.ADsPath) -eq $True){
    "User is member of group"
    }
else{
    "User is not member of group"
    }


More information about ADSI:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa772212(v=vs.85).aspx

More information about IADsGroup interface and IsMember method:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa706021(v=vs.85).aspx

No comments:

Post a Comment

Post a Comment