@@ -44,12 +44,13 @@ function Invoke-CIPPStandardMailContacts {
4444 return
4545 }
4646 $contacts = $settings
47- $TechAndSecurityContacts = @ ($Contacts .SecurityContact , $Contacts .TechContact )
47+ $TechAndSecurityContacts = @ (@ ( $contacts .SecurityContact , $contacts .TechContact ) | Where-Object { $_ } | Select-Object - Unique )
4848
49- $state = $CurrentInfo.marketingNotificationEmails -eq $Contacts.MarketingContact -and `
50- ($CurrentInfo.securityComplianceNotificationMails -in $TechAndSecurityContacts -or
51- $CurrentInfo.technicalNotificationMails -in $TechAndSecurityContacts ) -and `
52- $CurrentInfo.privacyProfile.contactEmail -eq $Contacts.GeneralContact
49+ $marketingMatch = @ ($CurrentInfo.marketingNotificationEmails ) -contains $contacts.MarketingContact
50+ $techMatch = -not (Compare-Object @ ($CurrentInfo.technicalNotificationMails ) $TechAndSecurityContacts )
51+ $generalMatch = $CurrentInfo.privacyProfile.contactEmail -eq $contacts.GeneralContact
52+
53+ $state = $marketingMatch -and $techMatch -and $generalMatch
5354
5455 if ($Settings.remediate -eq $true ) {
5556 if ($state ) {
@@ -105,13 +106,13 @@ function Invoke-CIPPStandardMailContacts {
105106 }
106107 if ($Settings.report -eq $true ) {
107108 $CurrentValue = @ {
108- marketingNotificationEmails = @ ($CurrentInfo.marketingNotificationEmails )
109- technicalNotificationMails = @ ($CurrentInfo.technicalNotificationMails )
109+ marketingNotificationEmails = @ ($CurrentInfo.marketingNotificationEmails | Sort-Object )
110+ technicalNotificationMails = @ ($CurrentInfo.technicalNotificationMails | Sort-Object )
110111 contactEmail = $CurrentInfo.privacyProfile.contactEmail
111112 }
112113 $ExpectedValue = @ {
113- marketingNotificationEmails = @ ($Contacts.MarketingContact )
114- technicalNotificationMails = @ (@ ($Contacts.SecurityContact , $Contacts.TechContact ) | Where-Object { $_ -ne $null } | Select-Object - Unique)
114+ marketingNotificationEmails = @ ($Contacts.MarketingContact | Sort-Object )
115+ technicalNotificationMails = @ (@ ($Contacts.SecurityContact , $Contacts.TechContact ) | Where-Object { $_ -ne $null } | Select-Object - Unique | Sort-Object )
115116 contactEmail = $Contacts.GeneralContact
116117 }
117118 Set-CIPPStandardsCompareField - FieldName ' standards.MailContacts' - CurrentValue $CurrentValue - ExpectedValue $ExpectedValue - Tenant $tenant
0 commit comments