Skip to content

Commit 2180c91

Browse files
committed
extract value from FileTypeAction
fixes ticket 34382084239
1 parent 6492331 commit 2180c91

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ function Invoke-CIPPStandardMalwareFilterPolicy {
7575

7676
try {
7777
$CurrentState = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MalwareFilterPolicy' |
78-
Where-Object -Property Name -EQ $PolicyName |
79-
Select-Object Name, EnableFileFilter, FileTypeAction, FileTypes, ZapEnabled, QuarantineTag, EnableInternalSenderAdminNotifications, InternalSenderAdminAddress, EnableExternalSenderAdminNotifications, ExternalSenderAdminAddress
80-
}
81-
catch {
78+
Where-Object -Property Name -EQ $PolicyName |
79+
Select-Object Name, EnableFileFilter, FileTypeAction, FileTypes, ZapEnabled, QuarantineTag, EnableInternalSenderAdminNotifications, InternalSenderAdminAddress, EnableExternalSenderAdminNotifications, ExternalSenderAdminAddress
80+
} catch {
8281
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
8382
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Could not get the MalwareFilterPolicy state for $Tenant. Error: $ErrorMessage" -Sev Error
8483
return
@@ -92,27 +91,29 @@ function Invoke-CIPPStandardMalwareFilterPolicy {
9291
$ExpectedFileTypes = $DefaultFileTypes + @($Settings.OptionalFileTypes.Split(',').Trim())
9392
}
9493

94+
$FileTypeAction = $Settings.FileTypeAction.value ?? $Settings.FileTypeAction ?? 'Quarantine'
95+
9596
$StateIsCorrect = ($CurrentState.Name -eq $PolicyName) -and
96-
($CurrentState.EnableFileFilter -eq $true) -and
97-
($CurrentState.FileTypeAction -eq $Settings.FileTypeAction) -and
98-
(!(Compare-Object -ReferenceObject $CurrentState.FileTypes -DifferenceObject $ExpectedFileTypes)) -and
99-
($CurrentState.ZapEnabled -eq $true) -and
100-
($CurrentState.QuarantineTag -eq $Settings.QuarantineTag) -and
101-
($CurrentState.EnableInternalSenderAdminNotifications -eq $Settings.EnableInternalSenderAdminNotifications) -and
102-
(($null -eq $Settings.InternalSenderAdminAddress) -or ($CurrentState.InternalSenderAdminAddress -eq $Settings.InternalSenderAdminAddress)) -and
103-
($CurrentState.EnableExternalSenderAdminNotifications -eq $Settings.EnableExternalSenderAdminNotifications) -and
104-
(($null -eq $Settings.ExternalSenderAdminAddress) -or ($CurrentState.ExternalSenderAdminAddress -eq $Settings.ExternalSenderAdminAddress))
97+
($CurrentState.EnableFileFilter -eq $true) -and
98+
($CurrentState.FileTypeAction -eq $FileTypeAction) -and
99+
(!(Compare-Object -ReferenceObject $CurrentState.FileTypes -DifferenceObject $ExpectedFileTypes)) -and
100+
($CurrentState.ZapEnabled -eq $true) -and
101+
($CurrentState.QuarantineTag -eq $Settings.QuarantineTag) -and
102+
($CurrentState.EnableInternalSenderAdminNotifications -eq $Settings.EnableInternalSenderAdminNotifications) -and
103+
(($null -eq $Settings.InternalSenderAdminAddress) -or ($CurrentState.InternalSenderAdminAddress -eq $Settings.InternalSenderAdminAddress)) -and
104+
($CurrentState.EnableExternalSenderAdminNotifications -eq $Settings.EnableExternalSenderAdminNotifications) -and
105+
(($null -eq $Settings.ExternalSenderAdminAddress) -or ($CurrentState.ExternalSenderAdminAddress -eq $Settings.ExternalSenderAdminAddress))
105106

106107
$AcceptedDomains = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-AcceptedDomain'
107108

108109
$RuleState = New-ExoRequest -tenantid $Tenant -cmdlet 'Get-MalwareFilterRule' |
109-
Where-Object -Property Name -EQ $RuleName |
110-
Select-Object Name, MalwareFilterPolicy, Priority, RecipientDomainIs
110+
Where-Object -Property Name -EQ $RuleName |
111+
Select-Object Name, MalwareFilterPolicy, Priority, RecipientDomainIs
111112

112113
$RuleStateIsCorrect = ($RuleState.Name -eq $RuleName) -and
113-
($RuleState.MalwareFilterPolicy -eq $PolicyName) -and
114-
($RuleState.Priority -eq 0) -and
115-
(!(Compare-Object -ReferenceObject $RuleState.RecipientDomainIs -DifferenceObject $AcceptedDomains.Name))
114+
($RuleState.MalwareFilterPolicy -eq $PolicyName) -and
115+
($RuleState.Priority -eq 0) -and
116+
(!(Compare-Object -ReferenceObject $RuleState.RecipientDomainIs -DifferenceObject $AcceptedDomains.Name))
116117

117118
if ($Settings.remediate -eq $true) {
118119

@@ -122,7 +123,7 @@ function Invoke-CIPPStandardMalwareFilterPolicy {
122123
$cmdParams = @{
123124
EnableFileFilter = $true
124125
FileTypes = $ExpectedFileTypes
125-
FileTypeAction = $Settings.FileTypeAction
126+
FileTypeAction = $FileTypeAction
126127
ZapEnabled = $true
127128
QuarantineTag = $Settings.QuarantineTag
128129
EnableInternalSenderAdminNotifications = $Settings.EnableInternalSenderAdminNotifications

0 commit comments

Comments
 (0)