May 29, 2013

If your corporate network happens to have Exchange 2010, chances are you may have employees with corporate email on their mobile devices. Exchange allows you to connect various mobile devices, whether tablets or smartphones, by way of Exchange ActiveSync (EAS). These devices may be part of a BYOD policy, or they may be provided by the company itself. In either event, you've got them tied to your Exchange server and as a Server Administrator, there may be a time where you need to report on what devices are currently synced.

Thankfully, with the installation of Exchange 2010 you will have access to a myriad of administrative tools, including numerous PowerShell cmdlets that can be ran through the Exchange Management Shell. You can find a complete list of cmdlets provided with Exchange 2010 on Microsoft's Technet page. One in particular is extremely useful in the task of reporting on ActiveSync devices, Get-ActiveSyncDevice.

Running this cmdlet as-is will provide you with an abundance of data in a not-so-user-friendly manner... so what do you do? If you've ever used PowerShell before, then you've probably used pipes to send the results of one cmdlet to another. This is very useful when you need to provide "cleaner" reports that include only the data you need, organized just the way you want it.

For example, let's take the output from Get-ActiveSyncDevice and pipe it into the Select-Object cmdlet in order to list only the objects we want to report on. So now we have:

Get-ActiveSyncDevice | Select-Object DeviceModel,FriendlyName,DeviceOS,UserDisplayName


This will now limit the data we will see for each ActiveSync device, but could still use some work to make it viewable within the PowerShell terminal. Let's pipe these results into the cmdlet Format-Table in order to size the table of data to the size of the PowerShell terminal:

Get-ActiveSyncDevice | Select-Object DeviceModel,FriendlyName,DeviceOS,UserDisplayName | FT -autosize -wrap


This should be much better than the original running of Get-ActiveSyncDevice, but let's say you want to sort the resulting data alphabetically by the DeviceModel object. To do this we'll add the Sort-Object cmdlet into the mix:

Get-ActiveSyncDevice | Select-Object DeviceModel,FriendlyName,DeviceOS,UserDisplayName | Sort-Object DeviceModel | FT -autosize -wrap


Now you should have the data you need, formatted just the way you want it. The only issue, it's still only viewable from within the PowerShell terminal. What if you want all of this formatted data in an Excel spreadsheet? PowerShell once again provides a way to do this, by way of yet another cmdlet. Let's replace the Format-Table cmdlet with Export-CSV to do this:

Get-ActiveSyncDevice | Select-Object DeviceModel,FriendlyName,DeviceOS,UserDisplayName | Sort-Object DeviceModel | Export-CSV -Path C:\ActiveSync-Devices.csv -NoTypeInformation


There you go! A well-formatted Excel spreadsheet containing all of the ActiveSync devices tied to your Exchange server.

0 comments:

Post a Comment

Subscribe to RSS Feed Follow me on Twitter!