I have a long list of email addresses/domains and I need to check if any of our mailboxes have received emails from them.
I can find how to search using the GUI but that will take too long. Found powershell commands for Exchange 365 but nothing for 2013.
A simple output to a file in the format...
address/domain,Yes|Nois sufficient. The list of addresses/domains will have to be read from text file.
Any ideas/examples?
EDIT 1: The following when run as the domain admin works...
Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery from:<text> -estimateresultonly but gives me a list of all mailboxes in the following format:
RunspaceId : f21e1a-42c-4b7-559-90c643f18
Identity : <blah/blah>
TargetMailbox :
Success : True
TargetFolder :
ResultItemsCount : 1
ResultItemsSize : 26.71 KB (27,350 bytes) 0 1 Answer
OK, after much googling, this will get me there. I need to wrap it in a loop but there are plenty of examples for that.
[PS] C:\>$t = (Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery from:@gmail.com -estimateresultonly | measure-object -Property ResultItemsCount -Sum).Sum WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified. To return more than 10000 results, use the New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the Exchange Administration Center. [PS] C:\>echo $t 30312The good thing is that the SearchQuery will handle partial addresses so that makes it easy.
I'll update this answer once I have the full script.