fix: 6.1.2/3 aligned with test-template
This commit is contained in:
@@ -2,6 +2,7 @@ function Test-MailboxAuditingE3 {
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
# Aligned
|
# Aligned
|
||||||
|
# Create Table for Details
|
||||||
# Parameters can be added if needed
|
# Parameters can be added if needed
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,12 +1,20 @@
|
|||||||
function Test-MailboxAuditingE5 {
|
function Test-MailboxAuditingE5 {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param ()
|
param (
|
||||||
|
# Aligned
|
||||||
|
# Create Table for Details
|
||||||
|
# Parameters can be added if needed
|
||||||
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# Dot source the class script if necessary
|
||||||
|
#. .\source\Classes\CISAuditResult.ps1
|
||||||
|
|
||||||
|
$e5SkuPartNumbers = @("SPE_E5", "ENTERPRISEPREMIUM", "OFFICEE5")
|
||||||
$AdminActions = @("ApplyRecord", "Copy", "Create", "FolderBind", "HardDelete", "MailItemsAccessed", "Move", "MoveToDeletedItems", "SendAs", "SendOnBehalf", "Send", "SoftDelete", "Update", "UpdateCalendarDelegation", "UpdateFolderPermissions", "UpdateInboxRules")
|
$AdminActions = @("ApplyRecord", "Copy", "Create", "FolderBind", "HardDelete", "MailItemsAccessed", "Move", "MoveToDeletedItems", "SendAs", "SendOnBehalf", "Send", "SoftDelete", "Update", "UpdateCalendarDelegation", "UpdateFolderPermissions", "UpdateInboxRules")
|
||||||
$DelegateActions = @("ApplyRecord", "Create", "FolderBind", "HardDelete", "MailItemsAccessed", "Move", "MoveToDeletedItems", "SendAs", "SendOnBehalf", "SoftDelete", "Update", "UpdateFolderPermissions", "UpdateInboxRules")
|
$DelegateActions = @("ApplyRecord", "Create", "FolderBind", "HardDelete", "MailItemsAccessed", "Move", "MoveToDeletedItems", "SendAs", "SendOnBehalf", "SoftDelete", "Update", "UpdateFolderPermissions", "UpdateInboxRules")
|
||||||
$OwnerActions = @("ApplyRecord", "Create", "HardDelete", "MailboxLogin", "Move", "MailItemsAccessed", "MoveToDeletedItems", "Send", "SoftDelete", "Update", "UpdateCalendarDelegation", "UpdateFolderPermissions", "UpdateInboxRules")
|
$OwnerActions = @("ApplyRecord", "Create", "HardDelete", "MailboxLogin", "Move", "MailItemsAccessed", "MoveToDeletedItems", "Send", "SoftDelete", "Update", "UpdateCalendarDelegation", "UpdateFolderPermissions", "UpdateInboxRules")
|
||||||
|
|
||||||
$auditResult = [CISAuditResult]::new()
|
$auditResult = [CISAuditResult]::new()
|
||||||
$auditResult.ELevel = "E5"
|
$auditResult.ELevel = "E5"
|
||||||
$auditResult.ProfileLevel = "L1"
|
$auditResult.ProfileLevel = "L1"
|
||||||
@@ -31,15 +39,11 @@ function Test-MailboxAuditingE5 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Define SKU Part Numbers for Office E5 licenses
|
|
||||||
# Define SKU Part Numbers for Office E5 licenses
|
|
||||||
$e5SkuPartNumbers = @("SPE_E5", "ENTERPRISEPREMIUM", "OFFICEE5")
|
|
||||||
$licenseDetails = Get-MgUserLicenseDetail -UserId $user.UserPrincipalName
|
$licenseDetails = Get-MgUserLicenseDetail -UserId $user.UserPrincipalName
|
||||||
$hasOfficeE5 = ($licenseDetails | Where-Object { $_.SkuPartNumber -in $e5SkuPartNumbers }).Count -gt 0
|
$hasOfficeE5 = ($licenseDetails | Where-Object { $_.SkuPartNumber -in $e5SkuPartNumbers }).Count -gt 0
|
||||||
Write-Verbose "Evaluating user $($user.UserPrincipalName) for Office E5 license."
|
Write-Verbose "Evaluating user $($user.UserPrincipalName) for Office E5 license."
|
||||||
if ($hasOfficeE5) {
|
if ($hasOfficeE5) {
|
||||||
$userUPN = $user.UserPrincipalName
|
$userUPN = $user.UserPrincipalName
|
||||||
|
|
||||||
$mailbox = Get-EXOMailbox -Identity $userUPN -PropertySets Audit
|
$mailbox = Get-EXOMailbox -Identity $userUPN -PropertySets Audit
|
||||||
|
|
||||||
$missingActions = @()
|
$missingActions = @()
|
||||||
@@ -78,13 +82,15 @@ function Test-MailboxAuditingE5 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($allFailures.Count -eq 0) {
|
# Prepare failure reasons and details based on compliance
|
||||||
Write-Verbose "All evaluated E5 users have correct mailbox audit settings."
|
$failureReasons = if ($allFailures.Count -eq 0) { "N/A" } else { "Audit issues detected." }
|
||||||
}
|
$details = if ($allFailures.Count -eq 0) { "All Office E5 users have correct mailbox audit settings." } else { $allFailures -join " | " }
|
||||||
|
|
||||||
|
# Populate the audit result
|
||||||
$auditResult.Result = $allFailures.Count -eq 0
|
$auditResult.Result = $allFailures.Count -eq 0
|
||||||
$auditResult.Status = if ($auditResult.Result) { "Pass" } else { "Fail" }
|
$auditResult.Status = if ($auditResult.Result) { "Pass" } else { "Fail" }
|
||||||
$auditResult.Details = if ($auditResult.Result) { "All Office E5 users have correct mailbox audit settings." } else { $allFailures -join " | " }
|
$auditResult.Details = $details
|
||||||
$auditResult.FailureReason = if (-not $auditResult.Result) { "Audit issues detected." } else { "N/A" }
|
$auditResult.FailureReason = $failureReasons
|
||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
@@ -117,4 +123,4 @@ function Format-MissingActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $formattedResults -join '; '
|
return $formattedResults -join '; '
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user