Looks for all mailboxes that have activesync device partnerships and then displays device information from these mailboxes only along with the mailbox owners identity in an easy to read format which can be customized.
$ActiveSyncDevices = @()
$mbx = get-casmailbox | ?{$_.hasactivesyncdevicepartnership -eq $true}
ForEach ($Mailbox in $mbx) {
Get-ActiveSyncDeviceStatistics -Mailbox $Mailbox.Identity –ErrorAction SilentlyContinue | Select DeviceFriendlyName, Devicetype, DeviceModel, DeviceOS, DeviceUserAgent | ForEach-Object { $_ | Add-Member –MemberType NoteProperty -Name \"MailboxIdentity\" -value $Mailbox;
$ActiveSyncDevices += $_ }
}
$ActiveSyncDevices | select DeviceType, DeviceModel, DeviceOS, MailboxIdentity | ft