Skip to content

Commit c0e8427

Browse files
Fix : Last Sync Attempt Time & Last Sync Success fields blank in ActiveSync Devices #5860 (KelvinTegelaar#2000)
Outlook for iOS/Android devices always show empty values for: lastSyncAttemptTime lastSuccessSync This is expected Exchange behavior, but: - The UI provides no explanation - Empty strings are indistinguishable from missing or broken data - Sorting and exporting these fields behaves inconsistently This PR : - Normalizes missing sync timestamps to null instead of empty strings. - Add a new informational field, syncInfoNote, for Outlook mobile devices explaining why ActiveSync sync times are not reported. - Detection is based on existing device properties (DeviceModel, DeviceType, ClientType) and does not introduce new protocol assumptions. Resolves - KelvinTegelaar/CIPP#5860
2 parents 0115569 + fa1620f commit c0e8427

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

Modules/CIPPHTTP/Public/Entrypoints/HTTP Functions/Email-Exchange/Reports/Invoke-ListActiveSyncDevices.ps1

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ function Invoke-ListActiveSyncDevices {
1212

1313
try {
1414
$GraphRequest = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-MobileDevice' -cmdParams @{ ResultSize = 'Unlimited' } |
15-
Select-Object @{ Name = 'userDisplayName'; Expression = { $_.UserDisplayName } },
16-
@{ Name = 'userPrincipalName'; Expression = { ($_.Identity -split '\\')[0] } },
17-
@{ Name = 'deviceFriendlyName'; Expression = { if ([string]::IsNullOrEmpty($_.FriendlyName)) { 'Unknown' } else { $_.FriendlyName } } },
18-
@{ Name = 'deviceModel'; Expression = { $_.DeviceModel } },
19-
@{ Name = 'deviceOS'; Expression = { $_.DeviceOS } },
20-
@{ Name = 'deviceType'; Expression = { $_.DeviceType } },
21-
@{ Name = 'clientType'; Expression = { $_.ClientType } },
22-
@{ Name = 'clientVersion'; Expression = { $_.ClientVersion } },
23-
@{ Name = 'deviceAccessState'; Expression = { $_.DeviceAccessState } },
24-
@{ Name = 'firstSyncTime'; Expression = { if ($_.FirstSyncTime) { $_.FirstSyncTime.ToString('yyyy-MM-ddTHH:mm:ssZ') } else { '' } } },
25-
@{ Name = 'lastSyncAttemptTime'; Expression = { if ($_.LastSyncAttemptTime) { $_.LastSyncAttemptTime.ToString('yyyy-MM-ddTHH:mm:ssZ') } else { '' } } },
26-
@{ Name = 'lastSuccessSync'; Expression = { if ($_.LastSuccessSync) { $_.LastSuccessSync.ToString('yyyy-MM-ddTHH:mm:ssZ') } else { '' } } },
27-
@{ Name = 'deviceID'; Expression = { $_.DeviceId } },
28-
@{ Name = 'identity'; Expression = { $_.Identity } },
29-
@{ Name = 'Guid'; Expression = { $_.Guid } }
15+
Select-Object @{ Name = 'userDisplayName'; Expression = { $_.UserDisplayName } },
16+
@{ Name = 'userPrincipalName'; Expression = { ($_.Identity -split '\\')[0] } },
17+
@{ Name = 'deviceFriendlyName'; Expression = { if ([string]::IsNullOrEmpty($_.FriendlyName)) { 'Unknown' } else { $_.FriendlyName } } },
18+
@{ Name = 'deviceModel'; Expression = { $_.DeviceModel } },
19+
@{ Name = 'deviceOS'; Expression = { $_.DeviceOS } },
20+
@{ Name = 'deviceType'; Expression = { $_.DeviceType } },
21+
@{ Name = 'clientType'; Expression = { $_.ClientType } },
22+
@{ Name = 'clientVersion'; Expression = { $_.ClientVersion } },
23+
@{ Name = 'deviceAccessState'; Expression = { $_.DeviceAccessState } },
24+
@{ Name = 'firstSyncTime'; Expression = {if ($_.FirstSyncTime) {$_.FirstSyncTime.ToString('yyyy-MM-ddTHH:mm:ssZ')} else {$null}}},
25+
@{ Name = 'lastSyncAttemptTime'; Expression = {if ($_.LastSyncAttemptTime) {$_.LastSyncAttemptTime.ToString('yyyy-MM-ddTHH:mm:ssZ')} else {$null}}},
26+
@{ Name = 'lastSuccessSync'; Expression = {if ($_.LastSuccessSync) {$_.LastSuccessSync.ToString('yyyy-MM-ddTHH:mm:ssZ')} else {$null}}},
27+
@{ Name = 'syncInfoNote'; Expression = {if ($_.DeviceModel -match 'Outlook' -or $_.DeviceType -eq 'Outlook' -or $_.ClientType -eq 'Outlook') {'Outlook for iOS and Android uses modern authentication and does not report ActiveSync sync times.'} else {$null}}},
28+
@{ Name = 'deviceID'; Expression = { $_.DeviceId } },
29+
@{ Name = 'identity'; Expression = { $_.Identity } },
30+
@{ Name = 'Guid'; Expression = { $_.Guid } }
31+
)
3032
$StatusCode = [HttpStatusCode]::OK
3133
} catch {
3234
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message

0 commit comments

Comments
 (0)