Office 365 Mail Traffic Statistics by User

This script connects to Office 365 and retrieves the inbound and outbound mail traffic statistics by recipient for all available dates. This information is then exported to a CSV file which can be opened in Microsoft Excel.

 
 
 
 
 
4.7 Star
(15)
19,860 times
Add to favorites
Office 365
1/17/2016
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Size
    1 Posts | Last post February 26, 2019
    • Hey Alan
      
      Thanks for great script. It worked smoothly and no changes are needed. I was just curious about output. Inbound size and outbound size is displayed in bytes or KB?
      
      
      Thanks once again.
      
      Anand
  • Is there a way to count attachments
    1 Posts | Last post October 19, 2018
    • Can you modify your script to count attachments? I use this $MailTraffic[$Message.RecipientAddress][$MessageDate]['Attachments']++ and it doesn't work count very well
      
      Thanks
  • Needs more details
    1 Posts | Last post April 19, 2018
    • Any way to make it somewhat similar to the script on this page?
      
      https://gallery.technet.microsoft.com/office/Exchange-200720102013-0ea7662b
      
      Only interested in adding unique messages count to the report. Unique internal and external.
  • Something similar by sender?
    1 Posts | Last post February 09, 2018
    • Do you have a similar script that sorts messages by the sender, not the recipient?
      Thanks!
      
      
  • Internal and External count?
    1 Posts | Last post November 07, 2017
    • Is there a way you can modify this script to include an external and internal report? Sent & Receive; External. Sent & Receive; Internal. 
      
      Thank you, 
      
      Patry T.
  • StartDate
    1 Posts | Last post June 02, 2017
    • Can't seem to be able to run the script with specific dates. 
      The csv file is generated but is empty
      
      $CurrMessages = Get-MessageTrace -PageSize 5000 -Page $Page -StartDate 04/15/2017 -EndDate 05/14/2017 | Select Received,SenderAddress,RecipientAddress,Size
  • Size
    1 Posts | Last post November 29, 2016
    • Hey Alan
      
      Thanks for great script. It worked smoothly and no changes are needed. I was just curious about output. Inbound size and outbound size is displayed in bytes or KB?
      I am trying to verify with few users (of course with those who have less mail send/receive items)and it is not matching.
      
      Thanks once again.
      
      Anand
  • Script is failing with at last op_Addition'
    2 Posts | Last post September 30, 2016
    • Here is error
      
      cmdlet Get-Credential at command pipeline position 1
      Supply values for the following parameters:
      Credential
      WARNING: Your connection has been redirected to the following URI:
      "https://ps.outlook.com/PowerShell-LiveID?PSVersion=5.1.14393.187 "
      WARNING: The names of some imported commands from the module 'tmp_ohcxxxqp.qsm' include unapproved verbs that might
      make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the
      Verbose parameter. For a list of approved verbs, type Get-Verb.
      Collecting Recipients...
      Collecting Message Tracking - Page 1...
      Collecting Message Tracking - Page 2...
      Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'.
      At C:\Users\balakr\Desktop\O365Scripts\O365MailTraffic\Get-DetailedMessageStats.ps1:71 char:5
      +     $Messages += $CurrMessages
      +     ~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
          + FullyQualifiedErrorId : MethodNotFound
      
      Crunching Results...
      Formatting Results...
      Results saved to DetailedMessageStats.csv
    • When I run second time, there is no error.
  • Only Getting 3 Days of Data
    6 Posts | Last post September 28, 2016
    • When I run the script, it is only returning the past 3 days of information.  Sorry if this has been asked before or if this is by design, but how do you increase?
      
      Thanks,
      
      Joel
    • I was able to get the cmd to stretch to 7 days by adding the -StartDate -EndDate. Odd, I set it to 30 days but it still only pulled 7. =\
      http://cl.ly/0n1C2l2h3K1l
    • Where are you adding the -StartDate -EndDate?
    • You can add it here if you wish:
      Get-MessageTrace -PageSize 5000 -Page $Page -StartDate mm/dd/yyyy -EndDate mm/dd/yyyy | Select Received,SenderAddress,RecipientAddress,Size 
      
      Hope this helps!
    • As far as I know MessagreTrace return only 7 days. If you want to information for more that 7 days old you need to use Start-HistoricalSearch.
    • The limit for dates of returned items is 7 days, and in practice I have found that it is often less.  There appears to be a maximum combination of the values for pagesize and page.  From my experience, the value of (pagesize * page) can never go higher than 1 million.  The acceptable values are 5000 and 1000 respectively, however if you were to run the script you would see the failures happen at precisely the point where the page value reaches 201 (because 201 * 5000 is the first combination past 1 million).  I have repeated this testing using other combinations, and it's always at the point it reaches 1 million.
      
      The error will look something like so:
      
      We cannot currently process your request, please wait a few minutes and try again.
          + CategoryInfo          : InvalidOperation: (:) [Get-MessageTrace], FfoReportingException
          + FullyQualifiedErrorId : [Server=DM5PR17MB1260,RequestId=610ab2d4-2600-439d-a1be-be3020e6e537,TimeStamp=9/27/2016 2:53:42 PM] [FailureCategory=Cmdlet-FfoReportingException 
         ] 8F93CBC9,Microsoft.Exchange.Management.FfoReporting.GetMessageTrace
          + PSComputerName        : ps.outlook.com
      
  • Int32 to Int64
    1 Posts | Last post August 29, 2016
    • Hi Alan,
      
      When I run the script, I receive the error "Exception setting "OutboundSize": "Value was either too large or too small for an
      Int32.Couldn't store <3842262700> in OutboundSize Column.  Expected type is Int32."
      At C:\Get-DetailedMessageStats.ps1:159 char:9
      +         $row.OutboundSize = $MailTraffic[$RecipientName][$Date].OutboundSize
      +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
          + FullyQualifiedErrorId : CatchFromBaseAdapterSetValue
      
      How do I edit the script to run in Int64?
1 - 10 of 41 Items