@@ -18,8 +18,10 @@ function Get-CIPPAlertMXRecordChanged {
1818
1919 $ChangedDomains = foreach ($Domain in $DomainData ) {
2020 $PreviousDomain = $PreviousResults | Where-Object { $_.Domain -eq $Domain.Domain }
21- if ($PreviousDomain -and $PreviousDomain.ActualMXRecords -ne $Domain.ActualMXRecords ) {
22- " $ ( $Domain.Domain ) : MX records changed from [$ ( $PreviousDomain.ActualMXRecords -join ' , ' ) ] to [$ ( $Domain.ActualMXRecords -join ' , ' ) ]"
21+ $PreviousRecords = $PreviousDomain.ActualMXRecords -split ' ,' | Sort-Object
22+ $CurrentRecords = $Domain.ActualMXRecords.Hostname | Sort-Object
23+ if ($PreviousDomain -and $PreviousRecords -ne $CurrentRecords ) {
24+ " $ ( $Domain.Domain ) : MX records changed from [$ ( $PreviousRecords -join ' , ' ) ] to [$ ( $CurrentRecords -join ' , ' ) ]"
2325 }
2426 }
2527
@@ -29,11 +31,12 @@ function Get-CIPPAlertMXRecordChanged {
2931
3032 # Update cache with current data
3133 foreach ($Domain in $DomainData ) {
34+ $CurrentRecords = $Domain.ActualMXRecords.Hostname | Sort-Object
3235 $CacheEntity = @ {
3336 PartitionKey = [string ]$TenantFilter
3437 RowKey = [string ]$Domain.Domain
3538 Domain = [string ]$Domain.Domain
36- ActualMXRecords = [string ]$Domain .ActualMXRecords
39+ ActualMXRecords = [string ]( $CurrentRecords -join ' , ' )
3740 LastRefresh = [string ]$Domain.LastRefresh
3841 MailProvider = [string ]$Domain.MailProvider
3942 }
0 commit comments