Dit regelen configureert spam notificaties admins via Microsoft Intune apparaat configuratie beleid of compliance policies om Windows endpoints te beveiligen volgens security best practices.
Vereisten
m365
Implementatie
Gebruik PowerShell-script spam-notificaties-admins.ps1 (functie Invoke-Monitoring) – Monitoren.
monitoring
Gebruik PowerShell-script spam-notifications-admins.ps1 (functie Invoke-Monitoring) – Controleren.
Remediatie
Gebruik PowerShell-script spam-notifications-admins.ps1 (functie Invoke-Remediation) – Herstellen.
Compliance en Auditing
Beleid documentatie
Compliance & Frameworks
CIS M365: Control 18.9.19.2 (L1) - CIS Security Benchmark aanbevelingen
BIO: 16.01 - BIO Baseline Informatiebeveiliging Overheid - 16.01 - Gebeurtenissen logging en audittrails
ISO 27001:2022: A.12.4.1 - ISO 27001:2022 - Gebeurtenissen logging en audittrails
Automation
Gebruik het onderstaande PowerShell script om deze security control te monitoren en te implementeren. Het script bevat functies voor zowel monitoring (-Monitoring) als remediation (-Remediation).
PowerShell
<#
.SYNOPSIS
Spam Notifications to Admins
.DESCRIPTION
Configures end-user spam notifications so users can manage their own quarantine.
Reduces admin workload while maintaining security.
.NOTES
Filename: spam-notifications-admins.ps1
Author: Nederlandse Baseline voor Veilige Cloud
.EXAMPLE
.\spam-notifications-admins.ps1 -Monitoring
Check spam notification configuration
#>#Requires -Version 5.1#Requires -Modules ExchangeOnlineManagement
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[switch]$Monitoring,
[Parameter(Mandatory = $false)]
[switch]$Remediation,
[switch]$Revert,
[switch]$WhatIf
)
$ErrorActionPreference = 'Stop'
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Spam Notifications Configuration" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
function Invoke-Monitoring {
function Invoke-Revert {
Write-Host "`nReverting configuration..." -ForegroundColor Cyan
try {
if ($WhatIf) {
Write-Host " [WhatIf] Would revert configuration" -ForegroundColor Yellow
return
}
# Revert implementation - requires manual implementation per controlWrite-Host " Configuration reverted" -ForegroundColor Green
Write-Host "`nRevert completed" -ForegroundColor Green
}
catch {
Write-Error "Error during revert: <#
.SYNOPSIS
Spam Notifications to Admins
.DESCRIPTION
Configures end-user spam notifications so users can manage their own quarantine.
Reduces admin workload while maintaining security.
.NOTES
Filename: spam-notifications-admins.ps1
Author: Nederlandse Baseline voor Veilige Cloud
.EXAMPLE
.\spam-notifications-admins.ps1 -Monitoring
Check spam notification configuration
#>#Requires -Version 5.1#Requires -Modules ExchangeOnlineManagement
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[switch]$Monitoring,
[Parameter(Mandatory=$false)]
[switch]$Remediation,
[switch]$Revert,
[switch]$WhatIf
)
$ErrorActionPreference = 'Stop'
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Spam Notifications Configuration" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
function Invoke-Monitoring {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Checking anti-spam policies for notifications..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy -ErrorAction Stop
$result = @{
totalPolicies = $policies.Count
withNotifications = 0
isCompliant = $false
}
foreach ($policy in $policies) {
$notificationsEnabled = $policy.SpamNotificationEnabled
if ($notificationsEnabled) {
$result.withNotifications++
$result.isCompliant = $trueWrite-Host " [OK] NOTIFICATIONS ENABLED: $($policy.Name)" -ForegroundColor Green
Write-Host " Frequency: Every $($policy.EndUserSpamNotificationFrequency) days" -ForegroundColor Cyan
Write-Host " Language: $($policy.EndUserSpamNotificationLanguage)" -ForegroundColor Cyan
}
else {
Write-Host " ⚠️ NOTIFICATIONS DISABLED: $($policy.Name)" -ForegroundColor Yellow
}
}
Write-Host "`n Total policies: $($result.totalPolicies)" -ForegroundColor Cyan
Write-Host " With user notifications: $($result.withNotifications)" -ForegroundColor $(
if ($result.withNotifications -gt 0) { 'Green' } else { 'Yellow' }
)
Write-Host "`n Recommendation: Enable for all policies, frequency 3 days" -ForegroundColor Cyan
if ($result.isCompliant) {
Write-Host "`n[OK] COMPLIANT" -ForegroundColor Green
exit 0
}
else {
Write-Host "`n⚠️ RECOMMENDED: Enable spam notifications" -ForegroundColor Yellow
exit 1
}
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
function Invoke-Remediation {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Enabling spam notifications for all policies..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy | Where-Object { -not $_.SpamNotificationEnabled }
if ($policies.Count -eq 0) {
Write-Host " [OK] All policies already have notifications enabled" -ForegroundColor Green
exit 0
}
$updated = 0foreach ($policy in $policies) {
try {
Set-HostedContentFilterPolicy -Identity $policy.Name `
-SpamNotificationEnabled $true `
-EndUserSpamNotificationFrequency 3 `
-EndUserSpamNotificationLanguage 'Default' `
-ErrorAction Stop
Write-Host " [OK] Enabled: $($policy.Name)" -ForegroundColor Green
$updated++
}
catch {
Write-Host " [FAIL] Failed: $($policy.Name) - $_" -ForegroundColor Red
}
}
Write-Host "`n[OK] Updated $updated policies" -ForegroundColor Green
Write-Host "Users will receive spam digest every 3 days" -ForegroundColor Cyan
exit 0
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
try {
if ($Monitoring) {
Invoke-Monitoring
}
elseif ($Remediation) {
Invoke-Remediation
}
else {
Write-Host "Use: -Monitoring or -Remediation" -ForegroundColor Yellow
}
}
catch {
throw
}
finally {
Write-Host "`n========================================`n" -ForegroundColor Cyan
}
"
throw
}
}
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Checking anti-spam policies for notifications..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy -ErrorAction Stop
$result = @{
totalPolicies = $policies.Count
withNotifications = 0
isCompliant = $false
}
foreach ($policy in $policies) {
$notificationsEnabled = $policy.SpamNotificationEnabled
if ($notificationsEnabled) {
$result.withNotifications++
$result.isCompliant = $trueWrite-Host " [OK] NOTIFICATIONS ENABLED: $($policy.Name)" -ForegroundColor Green
Write-Host " Frequency: Every $($policy.EndUserSpamNotificationFrequency) days" -ForegroundColor Cyan
Write-Host " Language: $($policy.EndUserSpamNotificationLanguage)" -ForegroundColor Cyan
}
else {
Write-Host " ⚠️ NOTIFICATIONS DISABLED: $($policy.Name)" -ForegroundColor Yellow
}
}
Write-Host "`n Total policies: $($result.totalPolicies)" -ForegroundColor Cyan
Write-Host " With user notifications: $($result.withNotifications)" -ForegroundColor $(
if ($result.withNotifications -gt 0) { 'Green' } else { 'Yellow' }
)
Write-Host "`n Recommendation: Enable for all policies, frequency 3 days" -ForegroundColor Cyan
if ($result.isCompliant) {
Write-Host "`n[OK] COMPLIANT" -ForegroundColor Green
exit 0
}
else {
Write-Host "`n⚠️ RECOMMENDED: Enable spam notifications" -ForegroundColor Yellow
exit 1
}
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
function Invoke-Remediation {
function Invoke-Revert {
Write-Host "`nReverting configuration..." -ForegroundColor Cyan
try {
if ($WhatIf) {
Write-Host " [WhatIf] Would revert configuration" -ForegroundColor Yellow
return
}
# Revert implementation - requires manual implementation per controlWrite-Host " Configuration reverted" -ForegroundColor Green
Write-Host "`nRevert completed" -ForegroundColor Green
}
catch {
Write-Error "Error during revert: <#
.SYNOPSIS
Spam Notifications to Admins
.DESCRIPTION
Configures end-user spam notifications so users can manage their own quarantine.
Reduces admin workload while maintaining security.
.NOTES
Filename: spam-notifications-admins.ps1
Author: Nederlandse Baseline voor Veilige Cloud
.EXAMPLE
.\spam-notifications-admins.ps1 -Monitoring
Check spam notification configuration
#>#Requires -Version 5.1#Requires -Modules ExchangeOnlineManagement
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[switch]$Monitoring,
[Parameter(Mandatory=$false)]
[switch]$Remediation,
[switch]$Revert,
[switch]$WhatIf
)
$ErrorActionPreference = 'Stop'
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Spam Notifications Configuration" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
function Invoke-Monitoring {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Checking anti-spam policies for notifications..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy -ErrorAction Stop
$result = @{
totalPolicies = $policies.Count
withNotifications = 0
isCompliant = $false
}
foreach ($policy in $policies) {
$notificationsEnabled = $policy.SpamNotificationEnabled
if ($notificationsEnabled) {
$result.withNotifications++
$result.isCompliant = $trueWrite-Host " [OK] NOTIFICATIONS ENABLED: $($policy.Name)" -ForegroundColor Green
Write-Host " Frequency: Every $($policy.EndUserSpamNotificationFrequency) days" -ForegroundColor Cyan
Write-Host " Language: $($policy.EndUserSpamNotificationLanguage)" -ForegroundColor Cyan
}
else {
Write-Host " ⚠️ NOTIFICATIONS DISABLED: $($policy.Name)" -ForegroundColor Yellow
}
}
Write-Host "`n Total policies: $($result.totalPolicies)" -ForegroundColor Cyan
Write-Host " With user notifications: $($result.withNotifications)" -ForegroundColor $(
if ($result.withNotifications -gt 0) { 'Green' } else { 'Yellow' }
)
Write-Host "`n Recommendation: Enable for all policies, frequency 3 days" -ForegroundColor Cyan
if ($result.isCompliant) {
Write-Host "`n[OK] COMPLIANT" -ForegroundColor Green
exit 0
}
else {
Write-Host "`n⚠️ RECOMMENDED: Enable spam notifications" -ForegroundColor Yellow
exit 1
}
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
function Invoke-Remediation {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Enabling spam notifications for all policies..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy | Where-Object { -not $_.SpamNotificationEnabled }
if ($policies.Count -eq 0) {
Write-Host " [OK] All policies already have notifications enabled" -ForegroundColor Green
exit 0
}
$updated = 0foreach ($policy in $policies) {
try {
Set-HostedContentFilterPolicy -Identity $policy.Name `
-SpamNotificationEnabled $true `
-EndUserSpamNotificationFrequency 3 `
-EndUserSpamNotificationLanguage 'Default' `
-ErrorAction Stop
Write-Host " [OK] Enabled: $($policy.Name)" -ForegroundColor Green
$updated++
}
catch {
Write-Host " [FAIL] Failed: $($policy.Name) - $_" -ForegroundColor Red
}
}
Write-Host "`n[OK] Updated $updated policies" -ForegroundColor Green
Write-Host "Users will receive spam digest every 3 days" -ForegroundColor Cyan
exit 0
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
try {
if ($Monitoring) {
Invoke-Monitoring
}
elseif ($Remediation) {
Invoke-Remediation
}
else {
Write-Host "Use: -Monitoring or -Remediation" -ForegroundColor Yellow
}
}
catch {
throw
}
finally {
Write-Host "`n========================================`n" -ForegroundColor Cyan
}
"
throw
}
}
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Enabling spam notifications for all policies..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy | Where-Object { -not $_.SpamNotificationEnabled }
if ($policies.Count -eq 0) {
Write-Host " [OK] All policies already have notifications enabled" -ForegroundColor Green
exit 0
}
$updated = 0foreach ($policy in $policies) {
function Invoke-Revert {
Write-Host "`nReverting configuration..." -ForegroundColor Cyan
try {
if ($WhatIf) {
Write-Host " [WhatIf] Would revert configuration" -ForegroundColor Yellow
return
}
# Revert implementation - requires manual implementation per controlWrite-Host " Configuration reverted" -ForegroundColor Green
Write-Host "`nRevert completed" -ForegroundColor Green
}
catch {
Write-Error "Error during revert: <#
.SYNOPSIS
Spam Notifications to Admins
.DESCRIPTION
Configures end-user spam notifications so users can manage their own quarantine.
Reduces admin workload while maintaining security.
.NOTES
Filename: spam-notifications-admins.ps1
Author: Nederlandse Baseline voor Veilige Cloud
.EXAMPLE
.\spam-notifications-admins.ps1 -Monitoring
Check spam notification configuration
#>#Requires -Version 5.1#Requires -Modules ExchangeOnlineManagement
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[switch]$Monitoring,
[Parameter(Mandatory=$false)]
[switch]$Remediation,
[switch]$Revert,
[switch]$WhatIf
)
$ErrorActionPreference = 'Stop'
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Spam Notifications Configuration" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
function Invoke-Monitoring {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Checking anti-spam policies for notifications..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy -ErrorAction Stop
$result = @{
totalPolicies = $policies.Count
withNotifications = 0
isCompliant = $false
}
foreach ($policy in $policies) {
$notificationsEnabled = $policy.SpamNotificationEnabled
if ($notificationsEnabled) {
$result.withNotifications++
$result.isCompliant = $trueWrite-Host " [OK] NOTIFICATIONS ENABLED: $($policy.Name)" -ForegroundColor Green
Write-Host " Frequency: Every $($policy.EndUserSpamNotificationFrequency) days" -ForegroundColor Cyan
Write-Host " Language: $($policy.EndUserSpamNotificationLanguage)" -ForegroundColor Cyan
}
else {
Write-Host " ⚠️ NOTIFICATIONS DISABLED: $($policy.Name)" -ForegroundColor Yellow
}
}
Write-Host "`n Total policies: $($result.totalPolicies)" -ForegroundColor Cyan
Write-Host " With user notifications: $($result.withNotifications)" -ForegroundColor $(
if ($result.withNotifications -gt 0) { 'Green' } else { 'Yellow' }
)
Write-Host "`n Recommendation: Enable for all policies, frequency 3 days" -ForegroundColor Cyan
if ($result.isCompliant) {
Write-Host "`n[OK] COMPLIANT" -ForegroundColor Green
exit 0
}
else {
Write-Host "`n⚠️ RECOMMENDED: Enable spam notifications" -ForegroundColor Yellow
exit 1
}
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
function Invoke-Remediation {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Enabling spam notifications for all policies..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy | Where-Object { -not $_.SpamNotificationEnabled }
if ($policies.Count -eq 0) {
Write-Host " [OK] All policies already have notifications enabled" -ForegroundColor Green
exit 0
}
$updated = 0foreach ($policy in $policies) {
try {
Set-HostedContentFilterPolicy -Identity $policy.Name `
-SpamNotificationEnabled $true `
-EndUserSpamNotificationFrequency 3 `
-EndUserSpamNotificationLanguage 'Default' `
-ErrorAction Stop
Write-Host " [OK] Enabled: $($policy.Name)" -ForegroundColor Green
$updated++
}
catch {
Write-Host " [FAIL] Failed: $($policy.Name) - $_" -ForegroundColor Red
}
}
Write-Host "`n[OK] Updated $updated policies" -ForegroundColor Green
Write-Host "Users will receive spam digest every 3 days" -ForegroundColor Cyan
exit 0
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
try {
if ($Monitoring) {
Invoke-Monitoring
}
elseif ($Remediation) {
Invoke-Remediation
}
else {
Write-Host "Use: -Monitoring or -Remediation" -ForegroundColor Yellow
}
}
catch {
throw
}
finally {
Write-Host "`n========================================`n" -ForegroundColor Cyan
}
"
throw
}
}
try {
Set-HostedContentFilterPolicy -Identity $policy.Name `
-SpamNotificationEnabled $true `
-EndUserSpamNotificationFrequency 3 `
-EndUserSpamNotificationLanguage 'Default' `
-ErrorAction Stop
Write-Host " [OK] Enabled: $($policy.Name)" -ForegroundColor Green
$updated++
}
catch {
Write-Host " [FAIL] Failed: $($policy.Name) - $_" -ForegroundColor Red
}
}
Write-Host "`n[OK] Updated $updated policies" -ForegroundColor Green
Write-Host "Users will receive spam digest every 3 days" -ForegroundColor Cyan
exit 0
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
function Invoke-Revert {
Write-Host "`nReverting configuration..." -ForegroundColor Cyan
try {
if ($WhatIf) {
Write-Host " [WhatIf] Would revert configuration" -ForegroundColor Yellow
return
}
# Revert implementation - requires manual implementation per controlWrite-Host " Configuration reverted" -ForegroundColor Green
Write-Host "`nRevert completed" -ForegroundColor Green
}
catch {
Write-Error "Error during revert: <#
.SYNOPSIS
Spam Notifications to Admins
.DESCRIPTION
Configures end-user spam notifications so users can manage their own quarantine.
Reduces admin workload while maintaining security.
.NOTES
Filename: spam-notifications-admins.ps1
Author: Nederlandse Baseline voor Veilige Cloud
.EXAMPLE
.\spam-notifications-admins.ps1 -Monitoring
Check spam notification configuration
#>#Requires -Version 5.1#Requires -Modules ExchangeOnlineManagement
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[switch]$Monitoring,
[Parameter(Mandatory=$false)]
[switch]$Remediation,
[switch]$Revert,
[switch]$WhatIf
)
$ErrorActionPreference = 'Stop'
Write-Host "`n========================================" -ForegroundColor Cyan
Write-Host "Spam Notifications Configuration" -ForegroundColor Cyan
Write-Host "========================================`n" -ForegroundColor Cyan
function Invoke-Monitoring {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Checking anti-spam policies for notifications..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy -ErrorAction Stop
$result = @{
totalPolicies = $policies.Count
withNotifications = 0
isCompliant = $false
}
foreach ($policy in $policies) {
$notificationsEnabled = $policy.SpamNotificationEnabled
if ($notificationsEnabled) {
$result.withNotifications++
$result.isCompliant = $trueWrite-Host " [OK] NOTIFICATIONS ENABLED: $($policy.Name)" -ForegroundColor Green
Write-Host " Frequency: Every $($policy.EndUserSpamNotificationFrequency) days" -ForegroundColor Cyan
Write-Host " Language: $($policy.EndUserSpamNotificationLanguage)" -ForegroundColor Cyan
}
else {
Write-Host " ⚠️ NOTIFICATIONS DISABLED: $($policy.Name)" -ForegroundColor Yellow
}
}
Write-Host "`n Total policies: $($result.totalPolicies)" -ForegroundColor Cyan
Write-Host " With user notifications: $($result.withNotifications)" -ForegroundColor $(
if ($result.withNotifications -gt 0) { 'Green' } else { 'Yellow' }
)
Write-Host "`n Recommendation: Enable for all policies, frequency 3 days" -ForegroundColor Cyan
if ($result.isCompliant) {
Write-Host "`n[OK] COMPLIANT" -ForegroundColor Green
exit 0
}
else {
Write-Host "`n⚠️ RECOMMENDED: Enable spam notifications" -ForegroundColor Yellow
exit 1
}
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
function Invoke-Remediation {
try {
Connect-ExchangeOnline -ShowBanner:$false -ErrorAction Stop
Write-Host "Enabling spam notifications for all policies..." -ForegroundColor Gray
$policies = Get-HostedContentFilterPolicy | Where-Object { -not $_.SpamNotificationEnabled }
if ($policies.Count -eq 0) {
Write-Host " [OK] All policies already have notifications enabled" -ForegroundColor Green
exit 0
}
$updated = 0foreach ($policy in $policies) {
try {
Set-HostedContentFilterPolicy -Identity $policy.Name `
-SpamNotificationEnabled $true `
-EndUserSpamNotificationFrequency 3 `
-EndUserSpamNotificationLanguage 'Default' `
-ErrorAction Stop
Write-Host " [OK] Enabled: $($policy.Name)" -ForegroundColor Green
$updated++
}
catch {
Write-Host " [FAIL] Failed: $($policy.Name) - $_" -ForegroundColor Red
}
}
Write-Host "`n[OK] Updated $updated policies" -ForegroundColor Green
Write-Host "Users will receive spam digest every 3 days" -ForegroundColor Cyan
exit 0
}
catch {
Write-Host "`n[FAIL] ERROR: $_" -ForegroundColor Red
exit 2
}
}
try {
if ($Monitoring) {
Invoke-Monitoring
}
elseif ($Remediation) {
Invoke-Remediation
}
else {
Write-Host "Use: -Monitoring or -Remediation" -ForegroundColor Yellow
}
}
catch {
throw
}
finally {
Write-Host "`n========================================`n" -ForegroundColor Cyan
}
"
throw
}
}
try {
if ($Monitoring) {
Invoke-Monitoring
}
elseif ($Remediation) {
Invoke-Remediation
}
else {
Write-Host "Use: -Monitoring or -Remediation" -ForegroundColor Yellow
}
}
catch {
throw
}
finally {
Write-Host "`n========================================`n" -ForegroundColor Cyan
}