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-ActiveSyncDeviceStatis tics | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)} | foreach-object {Remove-ActiveSyncDevice ([string]$_.Guid) -confirm:$false}
Is there a way to run this command on a specific server?
Get-ActiveSyncDevice -ResultSize unlimited | Get-ActiveSyncDeviceStatis
Activesync device partnerships are partnered to user account, not servers. And yes you can remove them with powershell.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can I also use this to export the results before deleting?
$Mailboxes = Get-CASMailbox -Filter {hasactivesyncdevicepartne rship -eq $true} -resultsize unlimited | Get-Mailbox | where{$_.servername -eq "MailboxServerName"}
ForEach($Mailbox in $Mailboxes){Get-ActiveSync DeviceStat istics -Mailbox $Mailbox.Identity | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)} | Export-CSV c:\activesync.csv}
$Mailboxes = Get-CASMailbox -Filter {hasactivesyncdevicepartne
ForEach($Mailbox in $Mailboxes){Get-ActiveSync