Skip to content

Commit 44bd89e

Browse files
committed
Update Invoke-CIPPStandardSpamFilterPolicy.ps1
1 parent acc9f5f commit 44bd89e

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardSpamFilterPolicy.ps1

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ function Invoke-CIPPStandardSpamFilterPolicy {
103103
$AcceptedDomains = New-ExoRequest -TenantId $Tenant -cmdlet 'Get-AcceptedDomain'
104104

105105
$RuleState = New-ExoRequest -TenantId $Tenant -cmdlet 'Get-HostedContentFilterRule' |
106-
Where-Object -Property Name -EQ $PolicyName |
107-
Select-Object -Property *
106+
Where-Object -Property Name -EQ $PolicyName |
107+
Select-Object -Property *
108108

109109
$RuleStateIsCorrect = ($RuleState.Name -eq $PolicyName) -and
110110
($RuleState.HostedContentFilterPolicy -eq $PolicyName) -and
@@ -147,13 +147,24 @@ function Invoke-CIPPStandardSpamFilterPolicy {
147147
InlineSafetyTipsEnabled = $true
148148
PhishZapEnabled = $true
149149
SpamZapEnabled = $true
150-
EnableLanguageBlockList = $Settings.EnableLanguageBlockList
151-
LanguageBlockList = $Settings.LanguageBlockList.value
152-
EnableRegionBlockList = $Settings.EnableRegionBlockList
153-
RegionBlockList = $Settings.RegionBlockList.value
154150
AllowedSenderDomains = $Settings.AllowedSenderDomains.value ?? @{'@odata.type' = '#Exchange.GenericHashTable' }
155151
}
156152

153+
# Remove optional block lists if not configured
154+
if ($Settings.EnableLanguageBlockList -eq $true) {
155+
$cmdParams.Add('EnableLanguageBlockList', $Settings.EnableLanguageBlockList)
156+
$cmdParams.Add('LanguageBlockList', $Settings.LanguageBlockList.value)
157+
} else {
158+
$cmdParams.Add('EnableLanguageBlockList', $false)
159+
}
160+
if ($Settings.EnableRegionBlockList -eq $true) {
161+
$cmdParams.Add('EnableRegionBlockList', $Settings.EnableRegionBlockList)
162+
$cmdParams.Add('RegionBlockList', $Settings.RegionBlockList.value)
163+
} else {
164+
$cmdParams.Add('EnableRegionBlockList', $false)
165+
}
166+
167+
157168
if ($CurrentState.Name -eq $PolicyName) {
158169
try {
159170
$cmdParams.Add('Identity', $PolicyName)

0 commit comments

Comments
 (0)