<

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

Published on
6,162 Points
2,362 Views
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.
 
3
  • 2
2 Comments
LVL 7

Author Comment

by:Marwan Osman
Thank You Sir.
0
LVL 7

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

Featured Post

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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 antispam), the admini…
Please check the video also in regards to recovery of deleted emails from office 365 admin center and through the MFCMAPI tool. I have mentioned each and every step with the proper steps that need to be taken care of.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month