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 = $_.name; $device = get-activesync devicestatistics -mailbox $_.identity; $device | foreach {write-host $mbx.name, $_.devicemodel, $_.devicephonenumber, $_.deviceid, $_.FirstSyncTime, $_.LastSuccessSync} }

10/2/2008

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 = $_.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

UPDATES

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.

{ 1 comment… read it below or add one }

Brian Murphy October 11, 2017 at 1:26 pm

I’ve found every iteration of how to export all devices to a CSV with all properties such as stated above and to the point of HTML report with pie chart but cannot find an example of a way to not get everyone. I need the ability for a team to populate a CSV (so IMPORT-CSV = XYZ), and only pull information on 10 people (example) versus return 50000 lines in Excel. No matter how I Google it, I only find ways to export all results which would take hours to refine down to say just these 50 people. There has to be a way to put SMTP addresses or user names or something to a CSV and foreach or pull that content in first then pipe to this command. I’ve checked Technet Scripting repository, tried different iterations trying to keep it simple but no matter what it returns everyone and everything.

Has anyone else seen a need for this and point me in the right direction?

Reply

Leave a Comment

Previous post:

Next post: