Don’t trust the result of a script using the attribute “HasActiveSyncDevicePartnership” in exchange server 2013

Published on
5,907 Points
3 Endorsements
Last Modified:
We were trying to find a script that returns the number of mobile devices synced to our Exchange Server 2013 per mailbox user, and we found this script:
$EASMailboxes = Get-CASMailbox -Filter {HasActiveSyncDevicePartnership -eq $True -and DisplayName -notlike "CAS_{*"} -ResultSize Unlimited | Get-Mailbox
$EASMailboxes | Select-Object SamAccountName, DisplayName, PrimarySMTPAddress, @{Name="EASDeviceCount";Expression={(Get-MobileDevice -Mailbox $_.Identity).Count}} | Export-CSV .\EASMailboxes.csv -NoTypeInformation

Open in new window

The script ran perfectly and returned a CSV file that contains the account, the display name, and the email address of each user has a synced mobile device(s) and the number of his synced mobile device(s). Also we found a script that returns a CSV file containing the names of the users and their synced mobile devices' models, the last sync time and other information. Find the script here: https://gallery.technet.microsoft.com/office/Generate-Reports-for-59557b49
The problem started when I found that my email was not included in the generated reports after running the above two scripts, and I found some emails that were included in the previous reports and missed in the latest updated reports, knowing that I and those email users are using the Exchange ActiveSync feature and have synced mobile devices.

I had started troubleshooting by opening the first script and reading it, and I noticed that the attribute that is used to filter the email addresses for users who have synced mobile devices is HasActiveSyncDevicePartnership.

I worked around the issue and opened the Exchange management shell and ran the cmdlet below:
Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true} -ResultSize unlimited > c:\Users.txt

Open in new window

After it was completed, I went to the users.txt  file and opened it and found that my email was not included even that I have a synced mobile device as mentioned before.

I immediately expected that there is a problem with the attribute hasactivesyncdevicepartnership, so I started a Google search about that attribute's problem, and found many technical and trusted blog spots talking about the wrong result of hasactivesyncdevicepartnership !

I decided to edit the above first script by removing HasActiveSyncDevicePartnership -eq $True and replacing it with ActiveSyncEnabled -eq $True

I ran the script and successfuly found my email address in the report associated with the number of the sync devices I have, and the same for all of the email addresses that were not included in the previous reports when running the original script. I also noticed that the total synced mobile devices in my exchange organization was 2000 devices, and it changed to around 3000 devices after editing the script, the real and correct number and result.
Hope the above is helpful for you and even that the filter ActiveSyncEnabled -eq $True will return some emails that have activesync enabled but don’t have device partnership but I consider that is better to get a wrong result and incorrect number of your exchange organization synced devices.
  • 2

Author Comment

by:Marwan Osman
Thank You Sir.

Author Comment

by:Marwan Osman
Sorry but I saw that the conclusion was missed to many words so I recopied the original one not only "who" thanks Sir for correcting.

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Join & Write a Comment

Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month