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
Settings.xml (default)
<?xml version="1.0"?> <Settings> <EmailSettings> <SMTPServer>smtp.mcsmemail.de</SMTPServer> <SMTPPort>25</SMTPPort> <MailFrom>postmaster@mcsmemail.de</MailFrom> <MailTo>postmaster@mcsmemail.de</MailTo> </EmailSettings> <OtherSettings> <!-- MobileDeviceLimit defines the overall threshold of mobile devices for a single user to synchronize. Default is 5. --> <MobileDeviceLimit>5</MobileDeviceLimit> <!-- AgedDeviceLimit defines the threshold of allowed aged devices for a single user to be removed. Default is 1. --> <AgedDeviceLimit>1</AgedDeviceLimit> <!-- Time threshold in days to identify old mobile devices, Be default devices not synchronized for 150 days will be removed --> <LastSyncDays>150</LastSyncDays> </OtherSettings> </Settings>
Steps being executed by the script:
# Example 1 # Remove old mobile device partnerships without sending a report email .\Remove-MobileDevicePartnership.ps1 # Example 2 # Remove old mobile device partnerships and send a report email .\Remove-MobileDevicePartnership.ps1 -SendMail # Example 3 # Search for old mobile device partnerships and write results as CSV to disk .\Remove-MobileDevicePartnership.ps1 -ReportOnly # Example 4 # Remove old mobile device partnerships for a single mailbox and send a report email .\Remove-MobileDevicePartnership.ps1 -MailboxFilter USERALIAS -SendMail