This script removes orphaned mobile device partnerships from Exchange Server 2013+ user mailboxes. Run the script as a scheduled task to maintain your Exchange Server environment properly.
This script utilizes a settings.xml file to configure
<!-- MobileDeviceLimit defines the overall threshold of mobile devices for a single user to synchronize. Default is 5. -->
<!-- AgedDeviceLimit defines the threshold of allowed aged devices for a single user to be removed. Default is 1. -->
<!-- Time threshold in days to identify old mobile devices, Be default devices not synchronized for 150 days will be removed -->
Steps being executed by the script:
# EXAMPLE 1
# Remove old mobile device partnerships without sending a report email
# Remove old mobile device partnerships and send a report email
# .\Remove-MobileDevicePartnership.ps1 -SendMail
It might happen that a mobile device running an Android operating system is not being redirected properly by the on-premises AutoDiscover service, when the mailbox has been migrated to Office 365.
If your device is not redirected, the device prefix is not recognized by Exchange Server and therefore not being redirected properly. The new device redirect feature for Android devices was introduced in Exchange Server 2010 SP3 RU9, Exchange Server 2013 CU8, and Exchange Server 2016.
The following device prefixes are known to Exchange by default:
If the device prefix of your device is not part of the default list, you can add the prefix to the AutoDiscover web.config file.
Add the device prefix to the MobileSyncRedirectBypassClientPrefixes key in the appSettings node.
<add key="LiveIdBasicAuthModule.AllowLiveIDOnlyAuth" value="true" />
<add key="LiveIdBasicAuthModule.ApplicationName" value="Microsoft.Exchange.Autodiscover" />
<add key="LiveIdBasicAuthModule.RecoverableErrorStatus" value="456" />
<add key="LiveIdBasicAuthModule.PasswordExpiredErrorStatus" value="457" />
<add key="ActiveManagerCacheExpirationIntervalSecs" value="5" />
<add key="ProxyRequestTimeOutInMilliSeconds" value="30000" />
<add key="LiveIdNegotiateAuxiliaryModule.AllowLiveIDOnlyAuth" value="true" />
<add key="TrustedClientsForInstanceBasedPerfCounters" value="bes" />
<add key="InstanceBasedPerfCounterTimeWindowInterval" value="900000" />
<add key="MobileSyncRedirectBypassEnabled" value="true" />
<add key="MobileSyncRedirectBypassClientPrefixes" value="Acer,ADR9,Ally,Amazon,Android,ASUS,EasClient,FUJITSU,HTC,HUAWEI,LG,LS,Moto,Mozilla,NEC,Nokia,Palm,PANASONIC,PANTECH,Remoba,Samsung,SEMC,SHARP,SONY-,TOSHIBA,Vortex,VS,ZTE" />
As always: Be careful when modifying application settings. Test such changes in a test environment first, if possible.
You need assistance with your Exchange Server setup? You have questions about your Exchange Server infrastructure and going hybrid? You are interested in what Exchange Server 2016 has to offer for your environment?
Contact me at firstname.lastname@example.org
Follow at https://twitter.com/stensitzki
This script removes orphaned ActiveSync device partnerships from Exchange Server 2010 user mailboxes. Run the script as a scheduled job to maintain your Exchange Server environment properly.
Modifiy the script path variables to fit your requirements. The variables are configured in the ### BEGIN Variables section.
Additional credits go to Sebastian Rubertus