As we all now know Exchange 2007 introduced Exchange Management Shell or EMS and at first I really was not that in love with the command line but as I got to know it better and started to see how useful it could be, my views started to change. I myself am not the best script person so I still fumble my ways through some scripts but have made vast improvements.

I have alway heard of the how Exchange puts the data in the pipeline and read Evans blog (http://msexchangeteam.com/articles/72684.aspx) about it but never really truely grasp the concept until Evan and I had an email conversation about it and it all sunk in.

I started to do some queries that where resource intensive and time consuming, do to the nature of my environment. For my lack of coding skills I would write the same line multiple times to get the data I wanted. I knew it was not efficient but it worked for me.

So lets say I wanted to see how many users where using Active Sync on the mail system
I would do somthing like this to get the data
Before###
(Get-mailbox -resultsize:unlimited % {Get-ActiveSyncDeviceStatistics -mailbox $_.alias}).count
This command would provide me with a count of the number of users

but now I also wanted to find out what phones they where using so I would write another line of code
(Get-mailbox -resultsize:unlimited % {Get-ActiveSyncDeviceStatistics -mailbox $_.alias}) ft identity,

You see this runs the same command 2 times and generates a lot of overhead

So lets look at how to use the pipline
Now#####
#Mobile Report#This script will get the number of user that have used mobile devices to
#sync. There could be more than 1 device per users#

#this clears the
screenclear-host

write-host -fore yellow “Please wait as the system runs the report this will take a few moments”
#Gets the count of user
$data=(Get-mailbox -resultsize:unlimited % {Get-ActiveSyncDeviceStatistics -mailbox $_.alias})


write-output “`nCurrently devices have synced with the system”

write-output $data.count
#This prints out the user identity which say the email address and device used
write-host -fore Green “`nThe following users have synced with the system”$data ft identity

You can see how I now run 1 queries but set the return to a variable of $data. This basically puts all the data in an Array that we can call on to access.

$data.count = returns the number of users
$data ft identity returns the identity field

By passing our data to a variable we can put the data in the pipline that can be accessed multiple time and maniupated w/o the overhead of multiple queries.

broken fences movie monster watchmen movie crew stargate continuum movies superhero movie changeling movie batman gotham knight wanted movie good dick imdb movie kill me later good movie monster the original movie its pat epic movie sweeney todd the demon barber of fleet street movie theater