Exchange

#PowerShell #Exchange Script for Messaging Tracking Logs Per User Stats

A few months ago I was working on collecting some statistics out of our Exchange environment.  I wanted to take a few samples of user specific message traffic to help with some sizing calculations and just do a sanity check on our existing usage.  I know there are other tools and utilities that exist, but I wanted try to write my own.  As a result, I added and defined the following requirements for this particular script:

  1. Hand it over to a Helpdesk Analyst and have the output make sense to them
  2. Consume the script logic into a much larger health and status check on a per user basis script.
  3. Make it possible for the scripts executor to have no knowledge of the Exchange environment other than having the Exchange Management tools installed.

A few challenges arose during this process:

  1. A multi-site Exchange environment requires Site & Hub Transport discovery of the site that the mailbox is homed.  If you were a Helpdesk Analyst you most likely wouldn’t know this information.
  2. There could be multiple Hub Transport servers in a site and message tracking events could exist on both.
  3. Performance hit on the Hub Transport servers in the event 30 days was opt’d for.

I’m not going to include the entire script in the body of this post, you can download it at the bottom, but I want to call out a few sections:

The logic behind the Site & Hub Transport discovery

Here is the cross selection of the script that requests the SMTP Address of the user who you want to report against.  From here we determine the Mailbox server and correlating AD Site.  Once we’ve determined the site we can then grab a list of Hub Transport servers to query against.

$user = Read-Host "What is the users email address?"
$MbxServer = (get-mailbox $user).Servername
$Site = (Get-exchangeserver $MbxServer).site.name
$SiteHTServers = Get-Exchangeserver | Where {($_.IsHubTransportServer -eq $true) -and ($_.site.name -like "$Site")}

The second and last second piece of logic I wanted to focus on is the use of a Switch statement which was new to me.  I’ve used Case statements in VB programming in my past, so it was relatively easy to understand. Essentially we are defining variables based the $DateInput variable which is the value the user enters interactively for the number of days.

switch ($DateInput)
    {
        1 {
           $StartDate = $today
           $Days = 1
           $SizeFactor = "1KB"
           $SizeLabel = "KB"
           break;
          }
        2 {
           $StartDate = (get-date).adddays(-7).ToString("MM/dd/yyyy")
           $Days = 7
           $SizeFactor = "1MB"
           $SizeLabel = "MB"
           break;
          }
        3 {
           $StartDate = (get-date).adddays(-14).ToString("MM/dd/yyyy")
           $Days = 14
           $SizeFactor = "1MB"
           $SizeLabel = "MB"
           break;
          }
        4 {
           $StartDate = (get-date).adddays(-30).ToString("MM/dd/yyyy")
           $Days = 30
           $SizeFactor = "1GB"
           $SizeLabel = "GB"
           break;
          }
        default {
           "** The selection could not be determined **";
           break;
          }
    }

You can download the full script here: get-messagetracking.txt


TechEd 2010 – Day 1

Day 1 was quite the experience.  From the huge amounts of attendees trying to walk, and ultimately coming to a halt, in a 25 foot wide hallway of session conference rooms, to getting to participate on an Exchange round table at the Rustynail with members of Exchange product team.

Sessions

This is my first time attending TechEd so I wasn’t quite sure what to expect.  I had heard mainly good things about it, but some “eeehhh” things.
After getting my Starbucks – they have one INSIDE the convention center – YES! – I found my seat in the jam packed keynote hall . Things started off with the Keynote which was lead by Microsoft’s Bob Muglia.  You can catch a web reply version here.  I, along with other attendees, thought it was a bit drawn out and could have been condensed.  There was two cool technologies that were demoed; The next version of Office Communications Server – rebranded as Microsoft Communications Server 2010.  We’re looking at deploying this when it RTM’s later this fall.  The client is extremely simplified for the users and eash to understand – something that hasn’t been Microsoft’s strong point.  They also demoed parts of the System Center Suite, namely Virtual Machine Manager 2011 Beta, which appears to bring a bucket full of new features.  It ended with Microsoft’s Tony Scott, their CIO, who isn’t presenter material.  I think his monotone voice put half the hall to sleep.

Following the keynote there were foundational sessions, none of which were interesting, so I opt’d to hit the exhibition floor and pick up swag.  Yup, the recession is over, vendors are giving away T-shirts regularly and offering varying raffles of Netbooks, iPads, and Xbox 360′s.

My afternoon was spent in breakout sessions.  Two were good, one, not so much.  Surprising the one that sucked was around automating IT with PowerShell – which I thought would have been great.  Let me explain, the subject is good, the presentation wasn’t.

Post Sessions

After the final session, there was an Exhibit Reception which was a way to get and keep attendees talking and providing vendors with the oh so important contact information to receive spam post conference.  I will say, offering tons of food and an open bar is a great way to achieve this.

After the Exhibition Reception, I headed over to the Exchange Roundtable that Jeff Guillet from Expta.com put together with about 20-25 other Exchange crazies.  He arranged for members of the Exchange product team to attend and participate in our discussions, notably Ross Smitth IV and Scott Schnoll.  It was a great evening and I enjoyed talking to the folks that attended.  There was a gentlemen that I actually didn’t get his name, but he was from Sweden and 1 of 5 Microsoft Certified Masters – Exchange 2010 in the world.  He shared that experience amongst many others.

Good times.


  • Disclaimer

    The views and opinions expressed on this site are mine and do not reflect those of my employer or anyone else.
  • RSSTwitter: jbarsodi

    • Twitter is sucking.
  • Copyright LDC - 1998-2010
    iDream theme by Templates Next | Powered by WordPress