Skip to content

Commit 4970b96

Browse files
committed
Fix: EntraConnectSyncStatus alert not showing why it triggers
Refactor to be a complex object with more info
1 parent 91cdf53 commit 4970b96

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Modules/CIPPCore/Public/Alerts/Get-CIPPAlertEntraConnectSyncStatus.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ function Get-CIPPAlertEntraConnectSyncStatus {
2020
$LastPasswordSync = $ConnectSyncStatus.onPremisesLastPasswordSyncDateTime
2121
$SyncDateTime = $ConnectSyncStatus.onPremisesLastSyncDateTime
2222
# Get the older of the two sync times
23-
$LastSync = if ($SyncDateTime -lt $LastPasswordSync) { $SyncDateTime } else { $LastPasswordSync }
23+
$LastSync = if ($SyncDateTime -lt $LastPasswordSync) { $SyncDateTime; $Cause = 'DirectorySync' } else { $LastPasswordSync; $Cause = 'PasswordSync' }
2424

2525
if ($LastSync -lt (Get-Date).AddHours(-$Hours).ToUniversalTime()) {
26-
$AlertData = "Entra Connect Sync for $($TenantFilter) has not run for over $Hours hours. Last sync was at $($LastSync.ToString('o'))"
26+
27+
$AlertData = @{
28+
Message = "Entra Connect $Cause for $($TenantFilter) has not run for over $Hours hours. Last sync was at $($LastSync.ToString('o'))"
29+
LastSync = $LastSync
30+
Cause = $Cause
31+
LastPasswordSync = $LastPasswordSync
32+
LastDirectorySync = $SyncDateTime
33+
Tenant = $TenantFilter
34+
}
2735
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
2836
}
2937
}

0 commit comments

Comments
 (0)