none
Exchange 2010如何统计用户每天发送邮件的总容量 RRS feed

  • 问题

  • 我已经通过Exchange Power Shell统计到邮箱用户发送邮件的总数量,但是不能统计到发送邮件的总容量

    如有大侠解决过此类问题,还请赐教,感谢!

    2014年9月4日 6:53

答案

  • 你好!

    你可以参考这个脚本来获得所有Exchange Mailbox的收件箱和发件箱的容量:

    $date = get-date
    #Author: Ed McKinzie
    
    $erroractionpreference = "SilentlyContinue" 
    $warningactionpreference = "SilentlyContinue"
     #View the Entire Forest
    Set-ADServerSettings -ViewEntireForest:$True
    [Array] $MailboxVariablesCollection = @() 
    
     # get all Mailboxes
    (Get-Mailbox -ResultSize Unlimited) | ForEach { 
    
     $erroractionpreference = "SilentlyContinue"
     $warningactionpreference = "SilentlyContinue"
       # Get the DisplayName, LastLogonTime, DatabaseName and TotalItemSize statistics 
       $MailboxStats = Get-MailboxStatistics $_.identity | Select DisplayName, LastLogonTime, DatabaseName, TotalItemSize 
    
       # Enumerate Sent, Junk-Email and Deleted Items 
       $mbSentStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Sent Items"} | Select ItemsInFolderAndSubfolders, @{name="SentItemsSize";expression={$_.FolderAndSubfolderSize.ToMB()}} 
       
       $mbDeletedStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Deleted Items"} | Select ItemsInFolderAndSubfolders, @{name="DeletedItemsSize";expression={$_.FolderAndSubfolderSize.ToMB()}} 
        
       #$mbJunkEmailStats = Get-MailboxFolderStatistics $_.identity –FolderScope JunkEmail | Select ItemsInFolderAndSubfolders,@{name="JunkEmailItemCount";expression={$_.FolderAndSubfolderSize.ToMB()}} 
        
       $mbJunkEmailStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Junk E-mail"} | Select ItemsInFolderAndSubfolders,@{name="JunkEmailItemCount";expression={$_.FolderAndSubfolderSize.ToMB()}} 
       
        $mbManagedFolderStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Managed Folders"} | Select ItemsInFolderAndSubfolders,@{name="ManagedFolderItemCount";expression={$_.FolderAndSubfolderSize.ToMB()}}
    
      $MailboxVariables = "" | Select "Display Name", "Last Logon Time", Database, "Mailbox Size (MB)", "Total Sent Items", "Sent Items Size (MB)", "Total Deleted Items", "Deleted Items Size (MB)", "JunkEmailItemCount", "TotalJunkEmailSizeMB","ManagedFolderItemCount","ManagedFolderEmailSizeMB","E-mail Address" 
    
       $MailboxVariables."Display Name" = $MailboxStats.DisplayName 
       $MailboxVariables."Last Logon Time" = $MailboxStats.LastLogonTime 
       $MailboxVariables.Database = $MailboxStats.DatabaseName 
       $MailboxVariables."Mailbox Size (MB)" = "{0:n2}" -f ($MailboxStats.TotalItemSize.Value.ToMB()) 
       $MailboxVariables."Total Sent Items" = "{0:n1}" -f ($mbSentStats.ItemsInFolderAndSubfolders)
       $MailboxVariables."Sent Items Size (MB)" = "{0:n2}" -f ($mbSentStats.SentItemsSize) 
       $MailboxVariables."Total Deleted Items" = "{0:n1}" -f ($mbDeletedStats.ItemsInFolderAndSubfolders)
       $MailboxVariables."Deleted Items Size (MB)" = "{0:n2}" -f ($mbDeletedStats.DeletedItemsSize)
    
       $MailboxVariables."TotalJunkEmailSizeMB" = "{0:n2}" -f ($mbJunkEmailStats.JunkEmailItemCount)
       $MailboxVariables."JunkEmailItemCount" = "{0:n1}" -f ($mbJunkEmailStats.ItemsInFolderAndSubfolders)
    
       $MailboxVariables."ManagedFolderEmailSizeMB" = "{0:n2}" -f ($mbManagedFolderStats.ManagedFolderItemCount)
       $MailboxVariables."ManagedFolderItemCount" = "{0:n1}" -f ($mbManagedFolderStats.ItemsInFolderAndSubfolders)
    
       $MailboxVariables."E-mail Address" = $_.PrimarySmtpAddress 
    
       $MailboxVariablesCollection += $MailboxVariables 
     } 
    
    $MailboxVariablesCollection #print the result
    
    $MailboxVariablesCollection | Export-Csv C:\MailboxStats.csv" -NoType #output the result to csv file

    Best Reagrds,

    Anna Wang

    2014年9月5日 8:23
    版主
  • 感谢!前些天我找了点资料,写了个脚本已经解决了,感谢!!

    [Int64] $intTotalSentSize = $intTotalSent = 0
    [Int64] $intTotalRecSize = $intTotalRec = 0

    Write-Host "From, To, # Sent, Size Sent, # Received, Size Received"

    #Do
    #{
     #Get-ExchangeServer | ? {$_.AdminDisplayVersion -match "8.3" -and $_.IsHubTransportServer -eq $True} | Get-MessageTrackingLog -ResultSize Unlimited -Start "9/3/2014" -end "9/4/2014" | ForEach {
     Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start "9/3/2014" -end "9/4/2014" | ? {$_.MessageSubject -ne "Folder Content"} | ForEach {
      # Sent E-mails
      If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
      {
       $intTotalSentSize += $_.TotalBytes
       $intTotalSent++
      }
      
      # Received E-mails
      If ($_.EventId -eq "DELIVER")
      {
       $intTotalRecSize += $_.TotalBytes
       $intTotalRec++
      }
     }

     # Convert the size to MB and round it
     $intTotalSentSize = [Math]::Round($intTotalSentSize/1MB, 0)
     $intTotalRecSize = [Math]::Round($intTotalRecSize/1MB, 0)

     
     Write-Host "$FromSmall, $TempTo, $intTotalSent, $intTotalSentSize, $intTotalRec, $intTotalRecSize"

     # Reset the variables to do another search
     #$intTotalSentSize = $intTotalSent = 0
     #$intTotalRecSize = $intTotalRec = 0
    #}

    pause

    2014年9月15日 4:26

全部回复

  • 你好!

    你可以参考这个脚本来获得所有Exchange Mailbox的收件箱和发件箱的容量:

    $date = get-date
    #Author: Ed McKinzie
    
    $erroractionpreference = "SilentlyContinue" 
    $warningactionpreference = "SilentlyContinue"
     #View the Entire Forest
    Set-ADServerSettings -ViewEntireForest:$True
    [Array] $MailboxVariablesCollection = @() 
    
     # get all Mailboxes
    (Get-Mailbox -ResultSize Unlimited) | ForEach { 
    
     $erroractionpreference = "SilentlyContinue"
     $warningactionpreference = "SilentlyContinue"
       # Get the DisplayName, LastLogonTime, DatabaseName and TotalItemSize statistics 
       $MailboxStats = Get-MailboxStatistics $_.identity | Select DisplayName, LastLogonTime, DatabaseName, TotalItemSize 
    
       # Enumerate Sent, Junk-Email and Deleted Items 
       $mbSentStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Sent Items"} | Select ItemsInFolderAndSubfolders, @{name="SentItemsSize";expression={$_.FolderAndSubfolderSize.ToMB()}} 
       
       $mbDeletedStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Deleted Items"} | Select ItemsInFolderAndSubfolders, @{name="DeletedItemsSize";expression={$_.FolderAndSubfolderSize.ToMB()}} 
        
       #$mbJunkEmailStats = Get-MailboxFolderStatistics $_.identity –FolderScope JunkEmail | Select ItemsInFolderAndSubfolders,@{name="JunkEmailItemCount";expression={$_.FolderAndSubfolderSize.ToMB()}} 
        
       $mbJunkEmailStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Junk E-mail"} | Select ItemsInFolderAndSubfolders,@{name="JunkEmailItemCount";expression={$_.FolderAndSubfolderSize.ToMB()}} 
       
        $mbManagedFolderStats = Get-MailboxFolderStatistics $_.identity | Where {$_.FolderPath -eq "/Managed Folders"} | Select ItemsInFolderAndSubfolders,@{name="ManagedFolderItemCount";expression={$_.FolderAndSubfolderSize.ToMB()}}
    
      $MailboxVariables = "" | Select "Display Name", "Last Logon Time", Database, "Mailbox Size (MB)", "Total Sent Items", "Sent Items Size (MB)", "Total Deleted Items", "Deleted Items Size (MB)", "JunkEmailItemCount", "TotalJunkEmailSizeMB","ManagedFolderItemCount","ManagedFolderEmailSizeMB","E-mail Address" 
    
       $MailboxVariables."Display Name" = $MailboxStats.DisplayName 
       $MailboxVariables."Last Logon Time" = $MailboxStats.LastLogonTime 
       $MailboxVariables.Database = $MailboxStats.DatabaseName 
       $MailboxVariables."Mailbox Size (MB)" = "{0:n2}" -f ($MailboxStats.TotalItemSize.Value.ToMB()) 
       $MailboxVariables."Total Sent Items" = "{0:n1}" -f ($mbSentStats.ItemsInFolderAndSubfolders)
       $MailboxVariables."Sent Items Size (MB)" = "{0:n2}" -f ($mbSentStats.SentItemsSize) 
       $MailboxVariables."Total Deleted Items" = "{0:n1}" -f ($mbDeletedStats.ItemsInFolderAndSubfolders)
       $MailboxVariables."Deleted Items Size (MB)" = "{0:n2}" -f ($mbDeletedStats.DeletedItemsSize)
    
       $MailboxVariables."TotalJunkEmailSizeMB" = "{0:n2}" -f ($mbJunkEmailStats.JunkEmailItemCount)
       $MailboxVariables."JunkEmailItemCount" = "{0:n1}" -f ($mbJunkEmailStats.ItemsInFolderAndSubfolders)
    
       $MailboxVariables."ManagedFolderEmailSizeMB" = "{0:n2}" -f ($mbManagedFolderStats.ManagedFolderItemCount)
       $MailboxVariables."ManagedFolderItemCount" = "{0:n1}" -f ($mbManagedFolderStats.ItemsInFolderAndSubfolders)
    
       $MailboxVariables."E-mail Address" = $_.PrimarySmtpAddress 
    
       $MailboxVariablesCollection += $MailboxVariables 
     } 
    
    $MailboxVariablesCollection #print the result
    
    $MailboxVariablesCollection | Export-Csv C:\MailboxStats.csv" -NoType #output the result to csv file

    Best Reagrds,

    Anna Wang

    2014年9月5日 8:23
    版主
  • 感谢!前些天我找了点资料,写了个脚本已经解决了,感谢!!

    [Int64] $intTotalSentSize = $intTotalSent = 0
    [Int64] $intTotalRecSize = $intTotalRec = 0

    Write-Host "From, To, # Sent, Size Sent, # Received, Size Received"

    #Do
    #{
     #Get-ExchangeServer | ? {$_.AdminDisplayVersion -match "8.3" -and $_.IsHubTransportServer -eq $True} | Get-MessageTrackingLog -ResultSize Unlimited -Start "9/3/2014" -end "9/4/2014" | ForEach {
     Get-TransportServer | Get-MessageTrackingLog -ResultSize Unlimited -Start "9/3/2014" -end "9/4/2014" | ? {$_.MessageSubject -ne "Folder Content"} | ForEach {
      # Sent E-mails
      If ($_.EventId -eq "RECEIVE" -and $_.Source -eq "STOREDRIVER")
      {
       $intTotalSentSize += $_.TotalBytes
       $intTotalSent++
      }
      
      # Received E-mails
      If ($_.EventId -eq "DELIVER")
      {
       $intTotalRecSize += $_.TotalBytes
       $intTotalRec++
      }
     }

     # Convert the size to MB and round it
     $intTotalSentSize = [Math]::Round($intTotalSentSize/1MB, 0)
     $intTotalRecSize = [Math]::Round($intTotalRecSize/1MB, 0)

     
     Write-Host "$FromSmall, $TempTo, $intTotalSent, $intTotalSentSize, $intTotalRec, $intTotalRecSize"

     # Reset the variables to do another search
     #$intTotalSentSize = $intTotalSent = 0
     #$intTotalRecSize = $intTotalRec = 0
    #}

    pause

    2014年9月15日 4:26