question

ChrisP-1496 avatar image
0 Votes"
ChrisP-1496 asked joyceshen-MSFT commented

Exchange Powershell: Wrong LDAP coding

$filter="{((((Company -eq 'XXXXXXXX') -and ((Title -eq 'Hauswirtschaft') -or (user.objectid -eq '2a424d65-88f1-49b5-87d8-2008c28e85b5')))) -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')))}

When using

Get-Recipient -RecipientPreviewFilter $filter | ft displayname, company, department, title

Ist says

for recipient preview is neither a valid OPath filter nor a valid LDAP filter. Use the '-RecipientPreviewFilter' parameter with either an existing
OPath filter string or with a valid LDAP filter string.
+ CategoryInfo: InvalidArgument: (:) [Get-Recipient], ArgumentException
+ FullyQualifiedErrorId: [Server=AM6PR08MB3655,RequestId=8bbcdb0f-7d08-4939-ae05-300a9aa36b0c,TimeStamp=15.02.2022 17:11:16] [FailureCategory=Cmdlet-ArgumentException] 1B362B53,Microsoft.Recip.ExientTasks.Management
recipient
+ PSComputer name: outlook.office365.com

What is wrong with the filter?


windows-server-powershelloffice-exchange-server-administration
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ChrisP-1496

I am writing to see how everything is going on with this thread. If you still have further concern on this, please feel free to let us know.


If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.




0 Votes 0 ·
RichMatheisen-8856 avatar image
1 Vote"
RichMatheisen-8856 answered RichMatheisen-8856 edited

According to the on-line Get-Recipient web information (get-recipient) the -RecipientPreviewFilter uses LDAP syntax.

Also, in your -RecipientPreviewFilter value you begin that string with "{((((Company -eq 'XXXXXXXX') and end it with 'SupervisoryReviewPolicyMailbox')))} -- and that's missing the terminating double-quote. You also include opening "{" and closing "}" characters surrounding the unterminated string. Those "{" and "}" are unnecessary.

You also have a user.objectid in your filter string. I'm assuming you mean only to use objectid.

If the on-line help for the Get-Recipient cmdlet is incorrect, and an OPATH filter is acceptable, I'd start by removing the "{" and "}" characters, adding the missing trailing double-quote, and using 'objectid' instead of 'user.objectid'.

You should also review the usable properties in OPATH queries (recipientfilter-properties) because "objectid" isn't in that list.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

joyceshen-MSFT avatar image
0 Votes"
joyceshen-MSFT answered joyceshen-MSFT commented

Hi @ChrisP-1496

I agree with the suggestions, the user.objectid is not a valid filterable recipient property. You may check if it should be ExchangeGuid or Guid.

     $filter="((((Company -eq 'XXXXXXXX') -and ( (Title -eq 'Hauswirtschaft') -or (ExchangeGuid -eq '2a424d65-88f1-49b5-87d8-2008c28e85b5')))) -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')))"

If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ChrisP-1496

Have you tried the suggestions above, any progress here about this issue so far?


If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 Votes 0 ·

Hi @ChrisP-1496

Feel free to share your update here if any, waiting for your feedback!


If an Answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 Votes 0 ·