Dynamic DL Exclusion

Copper Contributor

I am trying to exclude certain members in AD that belong to a specific company. It doesn't appear to work when I filter using the objects below:

 

Example -and (Company -ne 'Company A*'))

7 Replies
You cannot use wildcards with the -new operator.

@Vasil Michev 

 

What would be the best way to exclude those users? Would -ne not work?

It will work, but only when comparing against single value. Thus if you have multiple company names to check against, you have to include multiple statements. If you want to use wildcards, the -like operator will do.

I want to exclude Company A users so -like probably won't work. 

Use -notlike then. Or if you want to use a single value, -ne will also do (without the wildcard).

@Vasil Michev 

 

I tried this today and no users populated. What am I missing here?

-and (-not(Company - like 'Company A')

Looks OK to me, but post the full filter just in case. Also, if you are checking via Get-DynamicDistributionGroupMember, it takes some time for membership to be calculated.