Script: Remove Orphaned ActiveSync Devices

One of the customers is running cleanup of EAS devices. There goal is to remove all devices those haven’t synced with the server for more than 30 days. Approach is like below:

  1. Identify the users who’s activesync devices have not synced over last 30 days.
  2. Notify them about the removal and they should also know what devices are associated with their mailbox those will be removed.
  3. Remove the device after a notification is sent
  4. Log what was removed and who’s mailbox was processed

It is little tedious to do it manually since the initial number of users will be more than 1000, and yes that calls for an automated way to do it. Another reason of automating the process it to avoid any miss of schedule. Humans normally get busy with the things and they forget :). So, I wrote something that will do all mentioned jobs automatically and it goes hereimage


What you just need to do is change following information in the script at each of line number mentioned below:

105 – Company Policy Link
148 – Internal Phone Number
150 – External Phone Number
155 – Helpdesk Email Address
176 – Remove -WhatIf parameter
180 – Change the name of Hub Transport Server
143 – Change the name of Hub Transport Server


An output email that is sent out looks like below.




Hope you find it useful.