V
V
Vasya Pupkin2022-03-09 13:49:15
PowerShell
Vasya Pupkin, 2022-03-09 13:49:15

How to use filters in ExchangeOnline PowerShell selection?

Please help correct your request.

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery "from:[email protected] AND sent<=01/06/2021" -EstimateResultOnly -SearchDumpster:$false

This query searches all mailboxes for letters that have "this" sender and that the letter was sent before a certain date. The problem is that you need to look for sent letters that were sent within the company, i.e. where the recipient has the admin.com domain.
If you leave everything as it is, but it searches correctly except for the "specified mailbox". In it, he searches for all outgoing letters in general, tk. they satisfy the condition, and in it you need to search only for outgoing calls within the company.
When I substitute a query from KQL, it does not recognize it, so adding the "AND RecipientDomains:admin.com" condition does not work.

I ask for help in changing the request for PowerShell so that one of the options works:
1. Find an analogue of the "RecipientDomains" cmdlet so that you can search for letters sent within the domain.
2. Search all mailboxes (as done above) except for the specified mailbox [email protected] To make the search work for everything except him.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Bezrukov, 2022-03-09
@Desert-Eagle

$mbx = Get-Mailbox -ResultSize unlimited | where {$_.name -ne "admin"}
$mbx | Search-Mailbox -SearchQuery "from:[email protected] AND sent<=01/06/2021" -EstimateResultOnly -SearchDumpster:$false

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question