troubleshooting Question

match , notmatch operators and filtering

Avatar of davesnb
davesnbFlag for Canada asked on
Powershell
5 Comments1 Solution509 ViewsLast Modified:
I have a line of code below using the Quest.ActiveRoles.ADManagement snapin that will successfully find the users who are Domain Admins in the "testglobal" group . However, if I replace the -match with -notmatch it will display all users including the Domain Admins. I always thought conditional not operators are a true negative form. Is this not the case? Wondering if this is a bug or  because memberof is of type noteproperty perhaps I have to expand the list for the -notmatch?

Get-QADUser -memberof clientairglobal |where {($_.memberof -match "DomainAdmins")} | select name,memberof

Example output of -match

Name     : Joe Smith
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corporatedom,DC=ca, CN=CorporatedomGlobal,OU=Corporatedom,OU=ClientAccts,DC=Corporatedom,
           DC=ca, CN=Domain Admins,CN=Users,DC=Corporatedom,DC=ca}

Example output of -notmatch :

Name     : testBPS
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corpratedom,DC=ca}

Name     : cayekap2
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corpratedom,DC=ca}

Name     : cacsamgmt
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corpratedom,DC=ca}

Name     : caywgbag
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corpratedom,DC=ca}

Name     : caythacc8
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corpratedom,DC=ca}

Name     : Joe Smith
MemberOf : {CN=clientairGlobal,OU=clientair,OU=ClientAccts,DC=Corpratedom,DC=ca, CN=CorpratedomGlobal,OU=Corpratedom,OU=ClientAccts,DC=Corpratedom,
           DC=ca, CN=Domain Admins,CN=Users,DC=Corpratedom,DC=ca}
ASKER CERTIFIED SOLUTION
Gary Dewrell
Senior Network Administrator

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros