Avatar of davesnb
davesnb
Flag 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}
Powershell

Avatar of undefined
Last Comment
Gary Dewrell

8/22/2022 - Mon
Gary Dewrell

Davesnb it works for me. I did have to ad a space in "Domain Admins"
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
Gary Dewrell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
davesnb

ASKER
So that worked using the parameter, but wondering if this is a bug or I am misinterpreting the context of -notmatch.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Gary Dewrell

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. :)