11 November 2013

Remove activesync devices not synced for 60 days or more

For Exchange 2010:


Get all devices not synced for 60days or more:

$DevicesToRemove = Get-ActiveSyncDevice -result unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-60")}

Delete active sync devices from variable:

$DevicesToRemove | foreach-object {Remove-ActiveSyncDevice ([string]$_.Guid) -confirm:$false}

Remove Active sync device for specific user:

Get-ActiveSyncDevice -Mailbox "domain\username" | Remove-ActiveSyncDevice -Confirm:$true 


And for Exchange 2013:


Get all devices not synced for 60days or more:

$DevicesToRemove = Get-MobileDevice -ResultSize unlimited | Get-MobileDeviceStatistics | where {$_.LastSuccessSync -le (Get-Date).AddDays("-60")}

Delete active sync devices from variable:

$DevicesToRemove | foreach-object {Remove-MobileDevice ([string]$_.Guid) -confirm:$false} 

Remove Active sync device for specific user:

Get-Mobile -Mailbox "domain\username" | Remove-MobileDevice -Confirm:$true

No comments:

Post a Comment