Link to home
Start Free TrialLog in
Avatar of davesnb
davesnbFlag for Canada

asked on

match , notmatch operators and filtering

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}
Avatar of Gary Dewrell
Gary Dewrell
Flag of United States of America image

Davesnb it works for me. I did have to ad a space in "Domain Admins"
Avatar of davesnb

ASKER

There is a space ,sorry, the post should read :

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

output results are same, problem still exists
ASKER CERTIFIED SOLUTION
Avatar of Gary Dewrell
Gary Dewrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davesnb

ASKER

So that worked using the parameter, but wondering if this is a bug or I am misinterpreting the context of -notmatch.
Can't say for sure but my theory is that it is evaluating it on a group by group. So -nomatch is true for some of them.  Total guess though. Fortunatley Quest does a great job on thier tools.

I did add it to my list of questions to ask Microsoft at TechEd this year. :)