2010-05-04 42 views
0

我想統計與c#交換的未讀電子郵件 我全都接通了交換機,並獲得所有用戶和相應的電子郵件。爲每個用戶計算未讀電子郵件交換

爲我所擁有的連接..

RunspaceConfiguration rsConfig = RunspaceConfiguration.Create(); 
       PSSnapInException snapInException = null; 
       PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException); 
       Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig); 
       myRunSpace.Open(); 

       Pipeline pipeline = myRunSpace.CreatePipeline(); 
       Command myCommand = new Command("Get-Mailbox"); 

       pipeline.Commands.Add(myCommand); 

       Collection<PSObject> commandResults = pipeline.Invoke(); 

       // Ok, now we've got a bunch of mailboxes, cycle through them 
       foreach (PSObject mailbox in commandResults) 
       { 
        //define which properties to get 
        foreach (String propName in new string[] { "Name", "EmailAddresses", "Database", "OrganizationalUnit", "UserPrincipalName" }) 
        { 
         //grab the specified property of this mailbox 
         Object objValue = mailbox.Properties[propName].Value; 
....... 
+0

我不知道如何計算未讀電子郵件:S – Luis 2010-05-04 17:06:20

回答

1

你想要的命令是Get-MailboxStatistics。您可以將Inbox_Number_Unread關閉返回的對象。

Glen Scales發佈了this blog article關於通過PowerShell提取類似信息。它應該指向正確的方向。它有一個完整的腳本,收集所有郵箱的有用屬性。