2012-12-07 52 views
2

我真的不確定這是否可以使用Powershell,所以我想先在這裏問一個快速的頭腦風暴!基本上我需要通過在一個給定的Exchange的所有郵箱,尋找特定的字符串搜索 - 這些字符串的多種形式 - 在這種情況下,讓說 - 包含了一組6個號碼在以下任何格式的任何電子郵件:Powershell - 搜索Exchange郵箱和電子郵件

`xx-xx-xx 
xxxxxx 
xxx-xxx` 

這裏的x是一個數字。因此,如果這些字符串的郵件中發現,它記錄到一個文本文件中的郵箱和郵件/主題它包含在

我的邏輯將如下所示:

Search Exchange and loop for every mailbox 
Recurse in every mailbox looking for matches for the above criteria 
If it finds something - get info about that mail, write to text file 
Continue loop 

任何想法!

感謝

+0

Exchange版本? –

+0

對於2007年或2010年版本說實話 – PnP

回答

2

這是Exchange 2010從Exchange命令行管理程序:

#Assign the role to the required user account 
New-ManagementRoleAssignment -Role 「Mailbox Import Export」 -User administrator 
#Restart the shell 

#This would search every mailbox for messages containing the word xx-xx-xx in the message body, 
#and export them to the administrator mailbox in a subfolder called Export 
Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery 「Body:’*xx-xx-xx*’」 -TargetMailbox administrator -TargetFolder Export 

您需要爲您正在搜索的任何[string]做到這一點。 我想在2007年的交換中也有cmdlet可以做同樣的事情,但我可以發誓。

+0

謝謝 - 問題是xx-xx-xx可能是任何數字 - 我怎麼能搜索它的任何數字序列,而不是一個特定的?即。 「正文:'xx-xx-xx-xx'其中X是任何整數? – PnP

+0

@TheD。哎呀..你很...但不幸的是--searchquery不支持正則表達式。我嘗試搜索其他解決方案,但是這是一件困難的事情... –

+0

@TheD找不到任何與Exchange模塊的PowerShell。你可以嘗試搜索第三方工具。 –

相關問題