Files
ExchangeOnline/ActiveSync_Last30Days.ps1
2026-02-04 13:46:41 +00:00

31 lines
1.1 KiB
PowerShell

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