Skip to content

Commit 30c70e4

Browse files
committed
Update Invoke-CIPPStandardGlobalQuarantineNotifications.ps1
1 parent 5fd8030 commit 30c70e4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ function Invoke-CIPPStandardGlobalQuarantineNotifications {
6363
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Global Quarantine Notifications are already set to the desired value of $WantedState" -sev Info
6464
} else {
6565
try {
66-
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-QuarantinePolicy' -cmdParams @{Identity = $CurrentState.Identity; EndUserSpamNotificationFrequency = [string]$WantedState }
67-
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Set Global Quarantine Notifications to $WantedState" -sev Info
68-
} catch {
69-
try {
66+
if ($CurrentState.Name -eq 'DefaultGlobalPolicy') {
7067
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'New-QuarantinePolicy' -cmdParams @{ Name = 'DefaultGlobalTag'; QuarantinePolicyType = 'GlobalQuarantinePolicy'; EndUserSpamNotificationFrequency = [string]$WantedState.TotalHours }
71-
} catch {
72-
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
73-
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to set Global Quarantine Notifications to $WantedState. Error: $ErrorMessage" -sev Error
68+
} else {
69+
$null = New-ExoRequest -tenantid $Tenant -cmdlet 'Set-QuarantinePolicy' -cmdParams @{Identity = $CurrentState.Identity; EndUserSpamNotificationFrequency = [string]$WantedState }
7470
}
71+
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Set Global Quarantine Notifications to $WantedState" -sev Info
72+
} catch {
73+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
74+
Write-LogMessage -API 'Standards' -tenant $Tenant -message "Failed to set Global Quarantine Notifications to $WantedState. Error: $ErrorMessage" -sev Error
7575
}
7676
}
7777
}

0 commit comments

Comments
 (0)