diff --git a/ActiveSync_Last30Days.ps1 b/ActiveSync_Last30Days.ps1 new file mode 100644 index 0000000..3fab0e3 --- /dev/null +++ b/ActiveSync_Last30Days.ps1 @@ -0,0 +1,31 @@ +Connect-ExchangeOnline + +$since = (Get-Date).AddDays(-30) + +$devices = Get-MobileDevice -ResultSize Unlimited | +Where-Object { + ($_.ClientType -eq 'EAS' -or $_.ClientType -match 'ActiveSync') -and + $_.ClientVersion -and + ([version]$_.ClientVersion -lt [version]'16.1') +} + +$report = foreach ($d in $devices) { + $s = Get-MobileDeviceStatistics -Identity $d.Identity -ErrorAction SilentlyContinue + if ($s -and $s.LastSuccessSync -and $s.LastSuccessSync -ge $since) { + [pscustomobject]@{ + UserDisplayName = $d.UserDisplayName + Mailbox = $d.UserPrincipalName + DeviceId = $d.DeviceId + DeviceModel = $s.DeviceModel + DeviceOS = $s.DeviceOS + ClientType = $d.ClientType + ClientVersion = $d.ClientVersion + LastSuccessSync = $s.LastSuccessSync + FirstSyncTime = $s.FirstSyncTime + Status = $s.Status + } + } +} + +$report | Sort-Object UserDisplayName | Format-Table -AutoSize +$report | Export-Csv .\ActiveSync_Last30Days.csv -NoTypeInformation -Encoding UTF8 \ No newline at end of file