ActiveSync – list of devices synced in last 14 days.

If somebody would like to get a list of devices that are synced with Exchange here is a command, could be helpful for someone.

Get-Mailbox -ResultSize Unlimited -OrganizationalUnit 'OU=<YOUR_OU>,DC=<YOUR_DOMAIN>,DC=com' | foreach-object { Get-ActiveSyncDeviceStatistics -mailbox $_.alias |  where {$_.Lastsuccesssync -gt (Get-Date).AddDays("-14")} | foreach-object {$_.Identity} } |  export-csv c:\ActiveSyncList.csv -encoding unicode

It lists devices that have been synced during last 14 days, because sometimes people have old deviced that visible in Exchange.