fix: 2.1.1,2.1.4,2.1.5 surpress error messages and create a standard object when no e5
This commit is contained in:
@@ -33,13 +33,14 @@ function Test-SafeAttachmentsPolicy {
|
|||||||
- Condition D: The policy is disabled.
|
- Condition D: The policy is disabled.
|
||||||
#>
|
#>
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# Retrieve all Safe Attachment policies where Enable is set to True
|
||||||
|
$safeAttachmentPolicies = Get-SafeAttachmentPolicy | Where-Object { $_.Enable -eq $true }
|
||||||
|
if ($null -ne $safeAttachmentPolicies) {
|
||||||
try {
|
try {
|
||||||
# 2.1.4 (L2) Ensure Safe Attachments policy is enabled
|
# 2.1.4 (L2) Ensure Safe Attachments policy is enabled
|
||||||
|
|
||||||
# Retrieve all Safe Attachment policies where Enable is set to True
|
|
||||||
$safeAttachmentPolicies = Get-SafeAttachmentPolicy | Where-Object { $_.Enable -eq $true }
|
|
||||||
|
|
||||||
# Condition A: Check if any Safe Attachments policy is enabled
|
# Condition A: Check if any Safe Attachments policy is enabled
|
||||||
$result = $null -ne $safeAttachmentPolicies -and $safeAttachmentPolicies.Count -gt 0
|
$result = $null -ne $safeAttachmentPolicies -and $safeAttachmentPolicies.Count -gt 0
|
||||||
@@ -84,6 +85,17 @@ function Test-SafeAttachmentsPolicy {
|
|||||||
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$params = @{
|
||||||
|
Rec = $recnum
|
||||||
|
Result = $false
|
||||||
|
Status = "Fail"
|
||||||
|
Details = "No M365 E5 licenses found."
|
||||||
|
FailureReason = "The audit is for M365 E5 licenses and the required EXO commands will not be available otherwise."
|
||||||
|
}
|
||||||
|
$auditResult = Initialize-CISAuditResult @params
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return the audit result
|
# Return the audit result
|
||||||
|
@@ -31,12 +31,12 @@ function Test-SafeAttachmentsTeams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# Retrieve the ATP policies for Office 365 and check Safe Attachments settings
|
||||||
|
[void]($atpPolicies = Get-AtpPolicyForO365)
|
||||||
|
if ($null -ne $atpPolicies) {
|
||||||
try {
|
try {
|
||||||
# 2.1.5 (L2) Ensure Safe Attachments for SharePoint, OneDrive, and Microsoft Teams is Enabled
|
# 2.1.5 (L2) Ensure Safe Attachments for SharePoint, OneDrive, and Microsoft Teams is Enabled
|
||||||
|
|
||||||
# Retrieve the ATP policies for Office 365 and check Safe Attachments settings
|
|
||||||
$atpPolicies = Get-AtpPolicyForO365
|
|
||||||
|
|
||||||
# Check if the required ATP policies are enabled
|
# Check if the required ATP policies are enabled
|
||||||
$atpPolicyResult = $atpPolicies | Where-Object {
|
$atpPolicyResult = $atpPolicies | Where-Object {
|
||||||
$_.EnableATPForSPOTeamsODB -eq $true -and
|
$_.EnableATPForSPOTeamsODB -eq $true -and
|
||||||
@@ -87,6 +87,17 @@ function Test-SafeAttachmentsTeams {
|
|||||||
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$params = @{
|
||||||
|
Rec = $recnum
|
||||||
|
Result = $false
|
||||||
|
Status = "Fail"
|
||||||
|
Details = "No M365 E3 licenses found."
|
||||||
|
FailureReason = "The audit is for M365 E3 licenses, but no such licenses were found."
|
||||||
|
}
|
||||||
|
$auditResult = Initialize-CISAuditResult @params
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return the audit result
|
# Return the audit result
|
||||||
|
@@ -40,12 +40,12 @@ function Test-SafeLinksOfficeApps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
|
# Retrieve all Safe Links policies
|
||||||
|
[void]($policies = Get-SafeLinksPolicy)
|
||||||
|
if ($null -ne $policies) {
|
||||||
try {
|
try {
|
||||||
# 2.1.1 (L2) Ensure Safe Links for Office Applications is Enabled
|
# 2.1.1 (L2) Ensure Safe Links for Office Applications is Enabled
|
||||||
|
|
||||||
# Retrieve all Safe Links policies
|
|
||||||
$policies = Get-SafeLinksPolicy
|
|
||||||
|
|
||||||
# Initialize the details collection
|
# Initialize the details collection
|
||||||
$misconfiguredDetails = @()
|
$misconfiguredDetails = @()
|
||||||
|
|
||||||
@@ -97,6 +97,17 @@ function Test-SafeLinksOfficeApps {
|
|||||||
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
$auditResult = Initialize-CISAuditResult -Rec $recnum -Failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$params = @{
|
||||||
|
Rec = $recnum
|
||||||
|
Result = $false
|
||||||
|
Status = "Fail"
|
||||||
|
Details = "No M365 E5 licenses found."
|
||||||
|
FailureReason = "The audit is for M365 E5 licenses and the required EXO commands will not be available otherwise."
|
||||||
|
}
|
||||||
|
$auditResult = Initialize-CISAuditResult @params
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return the audit result
|
# Return the audit result
|
||||||
|
Reference in New Issue
Block a user