fix: 2.1.6 aligned with test-template

This commit is contained in:
DrIOS
2024-05-28 14:47:42 -05:00
parent deec4c4f5e
commit 050ea83acd

View File

@@ -1,16 +1,20 @@
function Test-SpamPolicyAdminNotify { function Test-SpamPolicyAdminNotify {
[CmdletBinding()] [CmdletBinding()]
param ( param (
# Aligned
# Parameters can be added if needed # Parameters can be added if needed
) )
begin { begin {
# Dot source the class script if necessary
#. .\source\Classes\CISAuditResult.ps1
# Initialization code, if needed
$auditResults = @() $auditResult = [CISAuditResult]::new()
} }
process { process {
# 2.1.6 Ensure Exchange Online Spam Policies are set to notify administrators # 2.1.6 Ensure Exchange Online Spam Policies are set to notify administrators
# Get the default hosted outbound spam filter policy # Get the default hosted outbound spam filter policy
$hostedOutboundSpamFilterPolicy = Get-HostedOutboundSpamFilterPolicy | Where-Object { $_.IsDefault -eq $true } $hostedOutboundSpamFilterPolicy = Get-HostedOutboundSpamFilterPolicy | Where-Object { $_.IsDefault -eq $true }
@@ -30,7 +34,6 @@ function Test-SpamPolicyAdminNotify {
} }
# Create an instance of CISAuditResult and populate it # Create an instance of CISAuditResult and populate it
$auditResult = [CISAuditResult]::new()
$auditResult.Status = if ($areSettingsEnabled) { "Pass" } else { "Fail" } $auditResult.Status = if ($areSettingsEnabled) { "Pass" } else { "Fail" }
$auditResult.ELevel = "E3" $auditResult.ELevel = "E3"
$auditResult.ProfileLevel = "L1" $auditResult.ProfileLevel = "L1"
@@ -45,14 +48,10 @@ function Test-SpamPolicyAdminNotify {
$auditResult.Result = $areSettingsEnabled $auditResult.Result = $areSettingsEnabled
$auditResult.Details = if ($areSettingsEnabled) { "Both BccSuspiciousOutboundMail and NotifyOutboundSpam are enabled." } else { $failureDetails -join ' ' } $auditResult.Details = if ($areSettingsEnabled) { "Both BccSuspiciousOutboundMail and NotifyOutboundSpam are enabled." } else { $failureDetails -join ' ' }
$auditResult.FailureReason = if (-not $areSettingsEnabled) { "One or both spam policies are not set to notify administrators." } else { "N/A" } $auditResult.FailureReason = if (-not $areSettingsEnabled) { "One or both spam policies are not set to notify administrators." } else { "N/A" }
$auditResults += $auditResult
} }
end { end {
# Return auditResults # Return auditResult
return $auditResults return $auditResult
} }
} }