List Exchange ActiveSync users and device information in Exchange 2007 and Exchange 2010

by Bharat Suneja

One of the requirements for managing mobile devices in an organization is reporting on users with a mobile device, the model or type of device, and optionally other information such as the DeviceID, the time of the last successful connection.

In How to get a list of Exchange ActiveSync users we list Exchange ActiveSync (EAS) users on Exchange 2007. You can use the Get-ActiveSyncDeviceStatistics cmdlet (Exchange 2010 SP1 version) to list EAS device statistics such as the device model number, device OS, device IMEI (International Mobile Equipment Identification, a 15 or 17-digit ID that uniquely identifies a specific phone or device on a mobile network— think of it as the hard-coded MAC address for a phone), last sync time, last policy update time, etc. for a mailbox user.

Get-ActivesyncDeviceStatistics -Mailbox [email protected]

The output:

FirstSyncTime : 12/22/2007 1:34:10 AM
LastPolicyUpdateTime : 12/22/2007 1:34:43 AM
LastSyncAttemptTime : 1/14/2008 7:45:15 AM
LastSuccessSync : 1/14/2008 7:45:15 AM
DeviceType : PocketPC
DeviceID : *******************************
DeviceUserAgent :
DeviceWipeSentTime :
DeviceWipeRequestTime :
DeviceWipeAckTime :
LastPingHeartbeat :
RecoveryPassword : ********
DeviceModel : WIZA100
DeviceIMEI : ************21900
DeviceFriendlyName : Pocket_PC
DeviceOS : Windows CE 5.2.19134
DeviceOSLanguage : English
DevicePhoneNumber : 1650*******
Identity : [email protected]\AirSync-PocketPC-*******************************

Note: The Identity, DeviceId, DeviceIMEI and DevicePhoneNumber properties are masked in the above output using the * character to protect identifiable information.

Some users may have more than 1 device, or perhaps the user simply got a new smartphone and the old device partnership has not been removed.

Here’s a a quick code snippet (it can probably be scrubbed up a little… ) that will list users and all their devices, along with first sync and last successful sync times:

$mbx = get-casmailbox | where {$_.hasactivesyncdevicepartnership -eq $true -and $_.identity -notlike “*CAS_{*”} ; $mbx | foreach {$name = $; $device = get-activesync devicestatistics -mailbox $_.identity; $device | foreach {write-host $, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }


Making it more efficient: Server-side filtering using the Filter parameter

Well, the above code could be scrubbed up a little. Rather than getting all mailboxes using Get-CASMailbox and filtering them on the client-side using the Where-Object cmdlet, a more efficient way of doing this is filtering on the server-side using the Get-Mailbox cmdlet with the -Filter parameter, and getting only the mailboxes which have an ActiveSync device partnershp.

Yes, I’ve just realized HasActiveSyncDevicePartnership is in fact a filterable property, listed under Advanced Filterable Properties in Filterable Properties for the -Filter Parameter in Exchange 2007 SP1.

Here’s the updated version:

$mbx = get-casmailbox -Filter {HasActivesyncDevicePartnership -eq $true -and -not DisplayName -like “CAS_{*”}; $mbx | foreach {$name = $; $device = get-activesync devicestatistics -mailbox $_.identity; $device | foreach {write-host $name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }

The output looks like this:

Bharat Suneja WIZA100 16501231234 353B7ACF5014C020CE22CBF1DB7FFD92 11/5/2007 7:41:29 AM 12/20/2007 11:00:15 PM
Bharat Suneja WIZA100 16501231234 7E6B67F47DFD370E89BE13280A75EAA5 12/22/2007 1:34:10 AM 1/14/2008 7


3/7/2012: Exchange 2010 also has the new Get-ActiveSyncDevice cmdlet you can use, although Get-ActiveSyncDeviceStatistics provides more details. Topic for a future post.

3/7/2012: The HasActiveSyncDevicePartnership property is set to true when the user connects to the mailbox using ActiveSync for the first time (and a device partnership is created). However, if you remove the last device from a mailbox using the Remove-ActiveSyncDevice cmdlet, the property isn’t flipped back to false. If it’s important that mailboxes with no device partnerships be returned, you may need to set the property to $false by running a command or script.

{ 2 comments… read them below or add one }

Leave a Comment

Previous post:

Next post: