Skip to content

Commit 79b314a

Browse files
committed
fix: state comparison for spoofwarn
fixes KelvinTegelaar/CIPP#4836
1 parent 2180c91 commit 79b314a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ function Invoke-CIPPStandardSpoofWarn {
4444

4545
try {
4646
$CurrentInfo = (New-ExoRequest -tenantid $Tenant -cmdlet 'Get-ExternalInOutlook')
47-
}
48-
catch {
47+
} catch {
4948
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
5049
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Could not get the SpoofWarn state for $Tenant. Error: $ErrorMessage" -Sev Error
5150
return
5251
}
5352

5453
# Get state value using null-coalescing operator
5554
$state = $Settings.state.value ?? $Settings.state
55+
56+
$IsEnabled = $state -eq 'enabled'
5657
$AllowListAdd = $Settings.AllowListAdd.value ?? $Settings.AllowListAdd
5758

5859
# Test if all entries in the AllowListAdd variable are in the AllowList
@@ -131,7 +132,7 @@ function Invoke-CIPPStandardSpoofWarn {
131132
if ($Settings.report -eq $true) {
132133
Add-CIPPBPAField -FieldName 'SpoofingWarnings' -FieldValue $CurrentInfo.Enabled -StoreAs bool -Tenant $Tenant
133134

134-
if ($AllowListCorrect -eq $true -and $CurrentInfo.Enabled -eq $status) {
135+
if ($AllowListCorrect -eq $true -and $CurrentInfo.Enabled -eq $IsEnabled) {
135136
$FieldValue = $true
136137
} else {
137138
$FieldValue = $CurrentInfo | Select-Object Enabled, AllowList

0 commit comments

Comments
 (0)