Forum Discussion
Basic user query in Exchange online (on way to create a DDL) "it's not getting what I want"
I have been trying to construct an additional DDL that won't work in the "canned queries".
Basically my logic was
company=RRR, State=NY OR State=Remote
The concept being get staff from company RRR that have either NY or Remote in the state field.
I'm getting nothing at all. (code will be below)
So what I'd like to try is just putting in search queries at a Exchange online CLI so I can build up my query from scratch. (i.e. I'd expect 150 for company=RRR and fewer as I add more query elements. That way I could check my logic one piece at a time.
The canned queries for this don't work since I'm asking for an OR not an AND.
I have also tried a canned query: Company=RRR, State=NY and attribute 1=Remote and get nobody. (which would make sense again since I still want OR.)
SO, I end up with the below doesn't work which means either my code is bad or my logic is bad. (and I'm not sure which since I'm getting no errors and it might BE doing just what I ask and my logic is bad)
HERE IS THE CODE
New-DynamicDistributionGroup -Name "RRR-All-US-employees2" ((((Company -eq 'RRR') -and (StateOrProvince -eq 'US' -or StateOrProvince -eq 'NY')
-and (RecipientType -eq 'UserMailbox'))) -and (-not(Name -like 'SystemMailbox{*')) -and (-not(Name -like 'CAS_{*')) -and (-not(RecipientTypeDetailsValue -eq 'MailboxPlan'))
-and (-not(RecipientTypeDetailsValue -eq 'DiscoveryMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'PublicFolderMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'ArbitrationMailbox')) -and
(-not(RecipientTypeDetailsValue -eq 'AuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'AuxAuditLogMailbox')) -and (-not(RecipientTypeDetailsValue -eq 'SupervisoryReviewPolicyMailbox'))
-and (-not(RecipientTypeDetailsValue -eq 'GuestMailUser')))
- The query seems OK, though you don't need to append the "system" part. How are you verifying the results? If using the Get-DynamicDistributionGroupMember, keep in mind that it can take up to 24 hours to get the correct results. Also, as this is an Exchange group, only valid recipients will be included. If you have users that are not licensed for Exchange (and not created as mail users), they will not appear.
- Tech_Guy-3000Copper Contributor
I'm verifying the results in powershell. Other DDL's that I test give me data this one does not. That's also why I want to be able to just put in a query at the CLI and test. If my query is ok than my logic is faulty ergo why I want to manually try some queries at the CLI. VasilMichev
- You can do so via the Get-Recipient -RecipientPreviewFilter cmdlet. Not every filter is supported for DDG, but most of the time it works.