Quantcast
Channel: Exchange Server 2013 - Mobility and ActiveSync forum
Viewing all articles
Browse latest Browse all 1206

Powershell to gather Activesync devices and remove if they have not synced in a year.

$
0
0

Hello,

Back in 2007 we had a script that would gather the devices + 365 days out of sync. I need to adapt this to 2010/2013

Output to check -

Get-CASMailbox -ResultSize unlimited -Filter{(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike "cas_*") -AND (name -notlike "DiscoverysearchMailbox*")} | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity | Where-Object {$_.LastSuccessSync -le (Get-Date).AddDays("-365")}|fl firstsynctime,lastsuccesssync,identity,deviceID,devicetype,deviceuseragent } > directory\filename.txt

Output to remove:

Get-CASMailbox -ResultSize unlimited -Filter{(HasActiveSyncDevicePartnership -eq $true) -AND (name -notlike "cas_*") -AND (name -notlike "DiscoverysearchMailbox*")} | ForEach {Get-ActiveSyncDeviceStatistics -Mailbox:$_.Identity | Where-Object {$_.LastSuccessSync -le (Get-Date).AddDays("-365")} | Remove-ActiveSyncDevice -confirm:$false} > directory\output.txt

Being new to shell I am having trouble updating to have this work in 2010/2013.


Viewing all articles
Browse latest Browse all 1206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>