#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


#PowerShell Date Countdown Fun

The other day I was trying to figure out how much longer until my anniversary date at work.  I figured I could open my Outlook calendar and start counting, but then I said, I bet this is easier to do in PowerShell!  So I goofed around and came up with the following.  I’m sure you could add a few more lines and loop through it to build a countdown script…

Here’s an example of how to use it.  Let’s say my anniversary date was October 1, 2010 or “10/01/10″ for this example.

First we want to figure out what today is using the Get-Date cmdlet.  Then we want to define our anniversary date and then take the difference of the two.

$today = Get-Date
$anniversary = "10/01/10"
[datetime]$anniversary - $today

This will generate output like similar to this:

Days              : 59
Hours             : 11
Minutes           : 30
Seconds           : 49
Milliseconds      : 80
Ticks             : 51390490805093
TotalDays         : 59.4797347281169
TotalHours        : 1427.51363347481
TotalMinutes      : 85650.8180084883
TotalSeconds      : 5139049.0805093
TotalMilliseconds : 5139049080.5093
While that might produce you what you want with a lot of information you don’t, you can simply use the Days property to output the number of days remaining.
$today = Get-Date
$anniversary = "10/01/10"
([datetime]$anniversary - $today).days
Which will return:
PS C:\> ([Datetime]$anniversary – $Today).days
59
Pretty simple.

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.


If only there was inflight WiFi on this plane

As I type this I’m cruising at 37,000 feet just south of the Sea of Okhotsk. We’re about 1025 miles from Narita airport according to this fancy LCD screen in front of me. I need to remain awake for another 6-8 hours to help with jet lag. We’ll see how successful I am at that as I have a 2hr bus ride to me hotel.


From the iPad

Just testing a post from my two day old iPad. I’m using the WordPress for iPad App and it’s pretty cool. Not super functional, but does allow for basic text input and post composition. All for now!


Storm and Bold, my new toys

Welp, today finally came…today as in the release date of the Blackberry Storm.  I picked one up this morning at 0′dark 30AM.  I was first in line and frooze my rear off in doing so, but it was worth it.  So far I’m   pleasantly surprised, it’s  better than my expectations and I really like it.  I also got a AT&T BB Bold this week at work and it’s definitely a sweet device. I can pound out emails like usual on it while the Storm’s SurePress will take some getting used to.  Both devices have beautiful displays, top notch for mobile devices…and arguably the best of any smartphones.

I’m going to need a few days to get used to the Storm’s SurePress technology.  I’ll report back after!

Here’s a pic of my new toys.

112108


Off to Get Married

I’ve been a bit busy lately and added a few domains to my hosting account, as a result, LDC was broke like a bad joke.  It’s fixed and back online, I know many were sad at it’s offlineness.

Anyways, I’m off getting married and on a 3 week hiatus.  Here’s proof, my desk at work…. I’ve never taken more than 4 days off work, hopefully I will still have a job when I return.

Desk @ work

Desk @ work


Helpdesk Hilarity

This week at work I was invited to join the Campus Slow down committee. We’ve been experiencing problems with different users varying from “Everything is slow” to “Outlook locks up”. Since I am responsible for the Email infrastructure, I got the invite, along with our LAN architect, Active Directory Administrators from each of our domains, Security representative, the SAP Administrator, the Helpdesk manager and her highest level help desk representative. We were reviewing the related tickets that the helpdesk manager brought to the meeting. Below is the one, that had the meeting pause while everyone busted up laughing including the Helpdesk manager.

** PHONE LOG 10/24/2006 08:54:00 AM
(Person Having the Problem): User’s Name
(Department/Physical Location): building b, 2nd floor
(Machine Name/IP Address): ComputerName
(Switch – Blade/Port Information):
User Name:
Host Name: Computername.domain.local
MAC Address: 12-34-56-78-90-11
IP Address: xxx.xxx.xxx.xxx
Subnet: xxx.xxx.xxx.xxx
Switch: ClosetLocation xxx.xxx.xxx.xxx
Port: 1/2
Port State: static
VLAN : VLAN NAME
Port Speed : 100M
Port Duplex : full-duplex
Last Seen 2006/10/13 14:57:18
(Top 2 Memory and CPU usage):
(Application): everything
(How Slow?): takes 2-3 minutes to open any application
(Description of problem): when she first boots up the computer in the morning, it takes *forever* to open programs. this lasts for several minutes, then goes back to normal-speed for the rest of the day.
(Time of Day/For how long): first thing in the morning
(Is the Problem Reproducible): yup
(Troubleshooting Steps Taken): told her it sounds like a combination of trying to open programs before the computer is all the way booted up, and virus scan loading and scanning files at bootup. advised her to boot up her computer, login, and then go get a cup of coffee to let the computer boot all the way before she tries to start her work in the morning.


T-Mobile Pearl 8100

Tonight I picked up my new Blackberry Pearl(8100) by T-Mobile. I must say, having owned/used the Blackberry 5790, 6750, 7750, 7250, 7130, 7520, 8700, and now the 8100 – the 8100 is my favorite.

This phone feels solid and feels right in your hand and on a call.

Tons of new features offered for the first time by Blackberry are:

  • Voice Activated Dialing
  • Bluetooth GPS compatibility w/ Blackberry Maps
  • Trackball/joystick – no more traditional Trackwheel
  • New style themes, similar to Pocket PC’s “Today” Screen
  • A 1.3MP camera
  • Media player – Movies, MP3’s
  • Stereo Headset
  • Expandable Memory slot – MicroSD
  • MP3 Ringtones – currently available on the 8700.

The phone came with OZ Instant Messaging Client. I’m not sure if this is a T-Mobile only included software or not. We’ll see when the Pearl comes out on Cingular sometime in November.

Check out a few pics:

091206-002091206-001

091206-003091206-004


  • 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