Skip to main content

Version 5 of the Mailbox Size Gui Script for Exchange 2007

***** If your running Exchange 2010 please see http://gsexdev.blogspot.com/2010/03/mailbox-size-gui-exchange-2010-remote.html ********

Okay time for a new version of the mailbox size gui the last version had a number of large bugs and the quota code looked like it had been written by a drunk squirrel. So this version firstly fixes the bugs in the quota code and the bugs with Deleted items sizes and adds some new functionality.

The first addition is a drop down box that allows selection of which quota value you want to report on Eg exchange offers 3 quota levels Warning, Prohibit Send and Prohibit Send and Receive so the script will now allow reporting on which ever Quota usage you want to look at. This section still needs a little work to get better performance as it re-queries the server for mailbox sizes when you change the quota dropdown box instead of just reusing the current result.

The second and most exciting feature is the mailbox size growth feature this is the biggest change and requires some explanation.

Firstly when the script runs now it will create a folder on the c drive called mbsizehistory, it will then record the results of each mailbox size query you make to a csv file in this directory with a serial date as the file name along with the servername . It will only create one file per day and per server you run it against.

So basically every time you run this script it will create this file so if you run it once a week or one a day or every three days you will start collecting adhoc history data about your mailbox size growth. Convention wisdom and what I’ve done in the past is record this type of data to a database every day and then build table, view and graph report on this data. While this is possible with the script the amount of complexity of setup and other backend you need starts getting beyond the technology that might be generally available for a simple script like this. But this where the cool and exciting part comes in to cater for this and allow aggregation of random history files using a few simple date algorithms, hash table and loops I’ve come up with a serial date, random file aggregation datatable. This part is highly experimental as it was only written last week so I haven’t tested it with real data only mock data and haven’t tested it with multiple servers so going on past experience the squirrel may make another appearance. But with the limited testing I’ve done it does work and I think its pretty cool and useful. Basically it aggregates the previous result from the files and tries to show the mailbox growth over 1 day,7days,1 month and 1 year. Because the dates of the file may be intermediate the script handles getting the file that is as closest to the growth date's as possible.

I’ve put a downloadable of the new version here the growth section looks like

function ShowGrowth(){


$gtTable.clear()
$datetime = get-date
$arArrayList = New-Object System.Collections.ArrayList
dir c:\mbsizehistory\*.csv | foreach-object{
$fname = $_.name
$nmArray = $_.name.split("-")
if ($nmArray[1].Replace(".csv","") -eq $snServerNameDrop.SelectedItem.ToString()) {
[VOID]$arArrayList.Add($nmArray[0])
}
}
$arArrayList.Sort()
$spoint = $arArrayList[$arArrayList.Count-1]
$oneday = $spoint
$sevenday = $spoint
$onemonth = $spoint
$oneyear = $spoint
foreach ($file in $arArrayList){
if ($file -gt ($datetime.Adddays(-2).ToString("yyyyMMdd")) -band $file -lt $oneday) {$oneday = $file}
if ($file -gt ($datetime.Adddays(-7).ToString("yyyyMMdd")) -band $file -lt $sevenday) {$sevenday = $file}
if ($file -gt ($datetime.Adddays(-31).ToString("yyyyMMdd")) -band $file -lt $onemonth) {$onemonth = $file}
if ($file -gt ($datetime.Adddays(-256).ToString("yyyyMMdd")) -band $file -lt $oneyear) {$oneyear = $file}
}
write-host $oneday
write-host $sevenday
write-host $onemonth
write-host $oneyear

$onedaystats = @{ }
$sevendaystats = @{ }
$onemonthsdaystats = @{ }
$oneyearstats = @{ }

Import-Csv ("c:\mbsizehistory\" + $oneday + "-" + $snServerNameDrop.SelectedItem.ToString() + ".csv") | %{
$onedaystats.add($_.DisplayName,$_.TotalItemSize)
}
Import-Csv ("c:\mbsizehistory\" + $sevenday + "-" + $snServerNameDrop.SelectedItem.ToString() + ".csv") | %{
$sevendaystats.add($_.DisplayName,$_.TotalItemSize)
}
Import-Csv ("c:\mbsizehistory\" + $onemonth + "-" + $snServerNameDrop.SelectedItem.ToString() + ".csv") | %{
$onemonthsdaystats.add($_.DisplayName,$_.TotalItemSize)
}
Import-Csv ("c:\mbsizehistory\" + $oneyear + "-" + $snServerNameDrop.SelectedItem.ToString() + ".csv") | %{
$oneyearstats.add($_.DisplayName,$_.TotalItemSize)
}

foreach($row in $msTable.Rows){
if ($onedaystats.ContainsKey($row[0].ToString())){
$ondaysizegrowth = $row[2] - $onedaystats[$row[0].ToString()]
}
else{$ondaysizegrowth = 0}
if ($sevendaystats.ContainsKey($row[0].ToString())){
$sevendaysizegrowth = $row[2] - $sevendaystats[$row[0].ToString()]}
else{$sevendaysizegrowth = 0}
if ($onemonthsdaystats.ContainsKey($row[0].ToString())){
$onemonthsizegrowth = $row[2] - $onemonthsdaystats[$row[0].ToString()]}
else{$onemonthsizegrowth = 0}
if ($oneyearstats.ContainsKey($row[0].ToString())){
$oneyearsizegrowth = $row[2] - $oneyearstats[$row[0].ToString()]}
else{$oneyearsizegrowth = 0}
$gtTable.rows.add($row[0].ToString(),$row[2],$ondaysizegrowth,$sevendaysizegrowth,$onemonthsizegrowth,$oneyearsizegrowth)

}
$dgDataGrid.DataSource = $gtTable

}


Popular posts from this blog

The MailboxConcurrency limit and using Batching in the Microsoft Graph API

If your getting an error such as Application is over its MailboxConcurrency limit while using the Microsoft Graph API this post may help you understand why. Background   The Mailbox  concurrency limit when your using the Graph API is 4 as per https://docs.microsoft.com/en-us/graph/throttling#outlook-service-limits . This is evaluated for each app ID and mailbox combination so this means you can have different apps running under the same credentials and the poor behavior of one won't cause the other to be throttled. If you compared that to EWS you could have up to 27 concurrent connections but they are shared across all apps on a first come first served basis. Batching Batching in the Graph API is a way of combining multiple requests into a single HTTP request. Batching in the Exchange Mail API's EWS and MAPI has been around for a long time and its common, for email Apps to process large numbers of smaller items for a variety of reasons.  Batching in the Gr...

Exporting and Uploading Mailbox Items using Exchange Web Services using the new ExportItems and UploadItems operations in Exchange 2010 SP1

Two new EWS Operations ExportItems and UploadItems where introduced in Exchange 2010 SP1 that allowed you to do a number of useful things that where previously not possible using Exchange Web Services. Any object that Exchange stores is basically a collection of properties for example a message object is a collection of Message properties, Recipient properties and Attachment properties with a few meta properties that describe the underlying storage thrown in. Normally when using EWS you can access these properties in a number of a ways eg one example is using the strongly type objects such as emailmessage that presents the underlying properties in an intuitive way that's easy to use. Another way is using Extended Properties to access the underlying properties directly. However previously in EWS there was no method to access every property of a message hence there is no way to export or import an item and maintain full fidelity of every property on that item (you could export the...

Sending a Message in Exchange Online via REST from an Arduino MKR1000

This is part 2 of my MKR1000 article, in this previous post  I looked at sending a Message via EWS using Basic Authentication.  In this Post I'll look at using the new Outlook REST API  which requires using OAuth authentication to get an Access Token. The prerequisites for this sketch are the same as in the other post with the addition of the ArduinoJson library  https://github.com/bblanchon/ArduinoJson  which is used to parse the Authentication Results to extract the Access Token. Also the SSL certificates for the login.windows.net  and outlook.office365.com need to be uploaded to the devices using the wifi101 Firmware updater. To use Token Authentication you need to register an Application in Azure https://msdn.microsoft.com/en-us/office/office365/howto/add-common-consent-manually  with the Mail.Send permission. The application should be a Native Client app that use the Out of Band Callback urn:ietf:wg:oauth:2.0:oob. You ...
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.