Link to home
Start Free TrialLog in
Avatar of toby_amsterdam
toby_amsterdam

asked on

Removing ActiveSync devices from specific servers

I have 3 exchange server in my environment and I'd like to remove old active sync partnerships (older than last sync 90 days) from each server individually.

Is there a way to run this command on a specific server?

Get-ActiveSyncDevice -ResultSize unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)} | foreach-object {Remove-ActiveSyncDevice ([string]$_.Guid) -confirm:$false}
Avatar of tshearon
tshearon
Flag of United States of America image

Activesync device partnerships are partnered to user account, not servers. And yes you can remove them with powershell.
ASKER CERTIFIED SOLUTION
Avatar of SreRaj
SreRaj
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of toby_amsterdam
toby_amsterdam

ASKER

Can I also use this to export the results before deleting?

$Mailboxes = Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true} -resultsize unlimited | Get-Mailbox | where{$_.servername -eq "MailboxServerName"}
ForEach($Mailbox in $Mailboxes){Get-ActiveSyncDeviceStatistics -Mailbox $Mailbox.Identity | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)} | Export-CSV c:\activesync.csv}