透過powershell搜尋所有Exchange 2013郵箱

透過powershell搜尋所有Exchange 2013郵箱

我有一長串電子郵件地址/網域,我需要檢查我們的郵箱是否收到了來自他們的電子郵件。

我可以找到如何使用 GUI 進行搜索,但這需要很長時間。找到了適用於 Exchange 365 的 powershell 指令,但沒有找到 2013 年的指令。

簡單輸出到以下格式的檔案...

address/domain,Yes|No

足夠了。位址/網域清單必須從文字檔案讀取。

有什麼想法/例子嗎?


編輯 1:以網域管理員身分執行時,以下內容有效...

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery from:<text> -estimateresultonly 

但給了我以下格式的所有郵箱的清單:

RunspaceId       : f21e1a-42c-4b7-559-90c643f18
Identity         : <blah/blah>
TargetMailbox    :
Success          : True
TargetFolder     :
ResultItemsCount : 1
ResultItemsSize  : 26.71 KB (27,350 bytes)

答案1

好的,經過大量谷歌搜索後,這會讓我到達那裡。我需要將其包裝在一個循環中,但有很多例子。

    [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
    30312

好處是 SearchQuery 將處理部分位址,這樣就變得容易。

一旦我有了完整的腳本,我就會更新這個答案。

相關內容