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

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:
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.

Comments (2)


Thank You Sir.


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.

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.