Expanded Folder Age and Attachment reporting for Trade / Workplace 365 Mailboxes with EWS and Powershell

Expanded Folder Age and Attachment reporting for Trade / Workplace 365 Mailboxes with EWS and Powershell Folder Merchandise numbers, dimension’s and Attachment Merchandise Numbers, varieties and sizes are one of many Mailbox statistics that’s helpful when your attempting to take a look at how and why a mailbox is rising or why your mailbox efficiency is likely to be declining when you’ve got a lot of folder gadgets. With the current will increase in Mailbox dimension quotas  in Workplace365 it may be simple to develop into fairly detached to how shortly your mailbox is likely to be rising. For instance when you’ve got 100GB quota the lazy mindset (which I admit to being part of) might be to simply maintain every thing you get through mail (or stack it and rack it). In case your customers aren’t in a position to make the most of cloudy attachments (or the customers refuse to vary their use habits) the character of increasing file sizes means a sharper development curve for Folder Objects and Attachments.

The normal manner of monitoring Mailbox sizes is to make use of Get-MailboxStatistics and Get-MailboxFolderStatistics for which there are lots of good scripts round that give a great overview of what’s in a Mailbox or Folder. For a deeper dive into what  is in messages in a selected folder the place you’re seeing development then utilizing a Mailbox API like EWS (or REST) might be helpful. Previously I’ve posted just a few scripts for doing Attachment and Merchandise stage statistics which the place in want of some updating which is what I’ve executed with this submit. 

Script Method 

For this script I’ve used EWS as it’s common throughout OnPremise and Workplace365 from Trade 2010 up. I do have two completely different variations of this script nevertheless as a result of Workplace365 and Trade 2016 permits you to have reference attachments (cloudy attachments) so some barely completely different code is required and the most recent compiled model of the EWS Managed API which is just obtainable from GitHub is required so statistics might be compiled efficiently for these kind of Attachments. For the Merchandise stage processing facet of the script it would course of each merchandise in a folder firstly utilizing the EWS FindItems operation which can return a minimal outcomes set of Objects and Sizes after which for these gadgets with Attachments one other batch operation is used to get the metadata for the attachments which can embrace the Attachment title (which we will then derive the attachment kind from utilizing the file extension title) and the dimensions of the attachment. If its a cloudy attachment then that is processed individually. I have not included any code to name out to OneDrive to get the filesize for the cloudy attachments however its doable to do that with some additional code (usually you’d need to do that asynchronously whereas processing the Trade attachments).

The Outcomes the script produces is the next html report

The script writes its consequence units out in JSON, I’ve then used the Tabulator JavaScript library http://tabulator.information/ which might flip JSON datasets into effectively formatted tables and supply sorting choices so its fairly simple to create a extra consumer pleasant outcomes set then only a plain CSV file which I often use. At the moment the script will report on only one specific folder as I envisaged that it could be greatest used along with different scripts (that make the most of Get-MailboxStatistics and Get-MailboxFolderStatistics eg take your choose from https://social.technet.microsoft.com/Search/en-US/workplace?question=Mailbox%20dimension%20report ) the place you determine a selected Mailbox or  folder you need to examine extra completely as this script can take a while to run. I even have two outlined modes the place you possibly can course of Inline Attachments (that are major simply picture information) or skip the processing of Inline attachments which can make the script run so much quicker due to the variety of Messages which have inline attachments.

Some Examples of operating the script on the Inbox folder with out processing Inline attachments




Import-Module .AttachmentStats.ps1


Invoke-MailboxFolderAttachmentReport -MailboxName [email protected]
mble.com -FolderPath Inbox -Verbose



Or with processing Inline attachments





Import-Module .AttachmentStats.ps1


Invoke-MailboxFolderAttachmentReport -MailboxName [email protected]
mble.com -FolderPath Inbox -IncludeInline -Verbose




The report might be saved to the identical path because the script module is situated.

The common model of the script might be discovered on GitHub https://github.com/gscales/Powershell-Scripts/blob/grasp/AttachmentStats.ps1

The cloudy model of the script might be discovered on GitHub right here https://github.com/gscales/Powershell-Scripts/blob/grasp/AttachmentStats-Cloudy.ps1 

The cloudy model would require the next EWS Managed API model https://github.com/gscales/Powershell-Scripts/uncooked/grasp/Microsoft.Trade.WebServices.dll to be situated in the identical listing because the script module.

The Cloudy model will produce a separate desk of cloudy attachment stats eg



Rent me – If you want to do one thing just like this or anything you see on my weblog I am at present obtainable to assist with any Workplace365, Trade or Energetic Listing associated growth work or scripting, please contact me at [email protected](nothing too huge or small).

Tags:

Related Posts

Leave a Reply