Remove stale ActiveSync Devices from Exchange 2010

Scenario: Exchange accounts have a max of 10 ActiveSync devices per account. This script will remove stale devices that are older then 180 days.

The initial report will take hrs to run. the code is listed below. This will run and export the results to a CSV file.
$DevicesToRemove = Get-ActiveSyncDevice -result unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays(“-180”)}| Export-CSV C:scriptsstaleeas.csv
The code below will remove the device by pulling the list from the CSV you created above.
import-staleeas.CSV | foreach-object {Remove-ActiveSyncDevice -Identity $_.guid -confirm:$False}
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: