• 1. London, UK
  • 2. New York, NY
  • 3. Sydney, Australia
  • 4. Melbourne, Australia
  • 5. Paris, France
  • 6. Bangalore, India
  • 7. Amsterdam, Netherlands
  • 8. San Francisco, CA
  • 9. Hong Kong
  • 10. Houston, TX

Friday, June 20, 2008

 

Exchange Server 2007: Listing Exchange ActiveSync users and device information

Posted by Bharat Suneja at 8:35 AM
In How to get a list of Exchange ActiveSync users we list EAS users on Exchange 2007. 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.

Output from Get-ActivesyncDeviceStatistics -mailbox foo@somedomain.com:


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 : foo@somedomain.com\AirSync-PocketPC-*******************************

The * characters in the Identity field are for the DeviceID.

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} }


Update: 10/2/2008:
Making it more efficient: Filtering on the server-side using -Filter
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 -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 $mbx.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

Labels: , ,

24 Comments:

October 8, 2008 4:03 PM
Anonymous Anonymous said...

Is there a shell command that will list all the users that have a mobile device and what the DeviceFriendlyName is? I know you can do it by mailbox using the command Get-ActiveSyncDeviceStatistics -Mailbox: "alias" however, I need to provide a list to management of what kinds of phones are connecting and from which department.
I did post this question on the Microsoft.Public.Exchange.Mobility newsgroup called "Shell command for all mobile devices?" However, I didn't receive a answer so John Oliver, Jr. [MVP] suggested that I contact you through your blog. Any help you can provide is appreciated

Thanks.
Penny

 
October 8, 2008 4:21 PM
Blogger Bharat Suneja said...

@Penny: The above command will get you the output you need. DeviceFriendlyName is one of the parameters output by Get-ActiveSynCDeviceStatistics.

Use this:
$mbx=get-casmailbox -Filter {HasActiveSyncDevicePartnership -eq $true -and -not Disp
layName -like "CAS_{*"};
$mbx | foreach {$name = $_.name; $identity = $_.identity; $device=get-activesyncdevi
cestatistics -mailbox $_.identity; $device | foreach {write-host $mbx.name, $_.devicefriendlyname, $
_.devicemodel, (get-user $identity).department} }

You can add additional fields such as first sync/last sync times or phone numbers as shown in the post.

 
October 8, 2008 5:44 PM
Anonymous Anonymous said...

That gets me in the right directions, thank you. I'm going home now so I'll work with this script again in the morning.

Penny

 
October 16, 2008 12:37 PM
Anonymous Anonymous said...

Any idea why I can never get a display name back as you have it?

Seems as if the $mbx.name portion is always blank.

Thanks

Jon

 
October 17, 2008 6:28 AM
Blogger tylergohl said...

I wasn't able to get the DisplayName or the Mailbox to show for me either, but the "Identity" property worked for me. Try this:

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


-- The addition of $_.Identity gave me what I needed. I don't know if this is the best way to go about getting it, maybe the original poster might know! ;) Seems like $mbx.name is intended to give the information we need, but doesn't seem to be working for me and the poster above me.

 
March 24, 2009 8:49 AM
Anonymous Anonymous said...

Does the –Filter applies to only Get-CasMailbox on the server side processing or does it also applies to pipelined cmd-let Get-ActiveSyncDeviceStatistics?

Since Get-ActiveSyncDeviceStatistics does not directly support –Filter I am not sure where the actual processing takes place.

 
March 24, 2009 8:57 AM
Blogger Bharat Suneja said...

@Anonymous from March 24: The filter applies to Get-CASMailbox, which returns a set of mailboxes after filtering it on server-side. You iterate through each mailbox returned (using the foreach), passing it on individually to Get-ActiveSyncDeviceStatistics.

 
March 24, 2009 2:09 PM
Anonymous Anonymous said...

But does the processing of "Get-ActiveSyncDeviceStatistics"
takes place on the client host CPU or the Server CPU?

@Anonymous from March 24:

 
June 17, 2009 7:06 AM
Blogger shali said...

How to filter the active sync users with department names?

 
July 21, 2009 9:11 AM
Anonymous D said...

@tylergohl : The command that you mentioned did not work for us. I have updated the command to include the following : $identity = $_.identity
After which the command worked like a charm.

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

 
August 20, 2009 8:05 AM
Anonymous Anonymous said...

this command is great, the question i have now is what can i run to disable activesync for everyone who does not come back from this query?

 
September 18, 2009 8:02 AM
Anonymous Anonymous said...

How do you get all of this to writ to a text file? I tried piping it with > c:\asu.txt at the end, but that did not work.

 
September 18, 2009 9:29 AM
Blogger Bharat Suneja said...

@Anonymous from Sep. 18th: You can use out-file or also look at export-csv.

 
October 19, 2009 7:17 AM
Anonymous Blueschica said...

When I try out-file or export-csv with this command it does not write to the csv file.

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

 
November 24, 2009 7:37 AM
Anonymous Anonymous said...

Blueschica, I was able to accomplish this by using a two-step process...try this:

1) At [PS] prompt, use the following (this should produce the results on screen):

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

2) After the result is returned, at the [PS], use the following (should use the $mbx information and write it to the designated file):

out-file -filepath C:\Test1\process.txt -inputobject $mbx -encoding ASCII -width 120

 
November 24, 2009 3:48 PM
Blogger Farhanible said...

Running something like "Get-ActivesyncDeviceStatistics -mailbox foo@somedomain.com" does not return anything for me (not even an error). I know the mailbox exists because I can also see that ActiveSync is enabled by doing a "Get-CASMailbox -identity [alias | mailbox]"


Anyone have an idea why?

We're running a mixed Exchange 2003 / 2007 environment with the AD schema updated for 2007. I have tried mailboxes residing on both 2003 and 2007 servers.

 
November 24, 2009 4:05 PM
Blogger Bharat Suneja said...

Simply having ActiveSync enabled does not mean there's a device partnership for the mailbox - all it means is a device will be able to connect. If there's no device, no statistics are returned.

Use the following command to determine if an ActiveSync partnership exists for the mailbox:
Get-CasMailbox foo@somedomain.com | Select identity,ActiveSyncEnabled,HasActiveSyncDevicePartnership

 
November 24, 2009 4:09 PM
Blogger Bharat Suneja said...

@Anonymouse from Nov. 24 7:37 AM: Thanks for responding!

 
November 25, 2009 9:17 AM
Blogger Farhanible said...

The mailbox I am testing against has 6 ActiveSync devices listed in the Mobile Admin console (running on an Exchange 2007 CAS). However, the mailbox resides on a Exchange 2003 server. The command you posted results in a 'false' answer for ActiveSync Partnership. I'm guessing this has something to do with the mixed 2003/2007 environment.

Thanks for the help.

 
November 25, 2009 9:45 AM
Blogger Bharat Suneja said...

@Farhanible: The cmdlet doesn't work against Exchange 2003 mailboxes. You can use the Microsoft Exchange Server ActiveSync Web Administration Tool (can only query one mailbox at a time) or LogParser to get this information.

 
November 30, 2009 9:06 AM
Blogger Farhanible said...

Yes, I have the MobileAdmin utility installed, which does its job well. However, I have a list of users that I need to report on. I'm modifying Glen's vbscript to make it work for my csv list of usernames. I'll post it here for everyone to use.

 
December 3, 2009 12:12 PM
Anonymous Anonymous said...

I can't get all the informaion from the command to a text or csv file. Has anyone been able to capture all the data?

 
December 18, 2009 1:57 AM
Blogger divya said...

Hi,
How to get the Activesync mailbox statitistics for 1 complete server or Entire users in a domain

Regards,
Divyakumar

 
December 18, 2009 1:59 AM
Blogger divya said...

Hi,
How should i get the Activesync statistics for all the users in an organisation?

 

Post a Comment

Links to this post:

Create a Link

<< Home