fix: 6.5.1 aligned with test-template
This commit is contained in:
@@ -1,40 +1,49 @@
|
|||||||
function Test-ModernAuthExchangeOnline {
|
function Test-ModernAuthExchangeOnline {
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
|
# Aligned
|
||||||
# Define your parameters here
|
# Define your parameters here
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
|
# Dot source the class script if necessary
|
||||||
$auditResults = [CISAuditResult]::new()
|
#. .\source\Classes\CISAuditResult.ps1
|
||||||
# Initialization code
|
# Initialization code, if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
try {
|
try {
|
||||||
# Ensuring the ExchangeOnlineManagement module is available
|
# Ensuring the ExchangeOnlineManagement module is available
|
||||||
|
|
||||||
|
|
||||||
# 6.5.1 (L1) Ensure modern authentication for Exchange Online is enabled
|
# 6.5.1 (L1) Ensure modern authentication for Exchange Online is enabled
|
||||||
$orgConfig = Get-OrganizationConfig | Select-Object -Property Name, OAuth2ClientProfileEnabled
|
$orgConfig = Get-OrganizationConfig | Select-Object -Property Name, OAuth2ClientProfileEnabled
|
||||||
|
|
||||||
# Create an instance of CISAuditResult and populate it
|
# Prepare failure reasons and details based on compliance
|
||||||
|
$failureReasons = if (-not $orgConfig.OAuth2ClientProfileEnabled) {
|
||||||
|
"Modern authentication is disabled"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"N/A"
|
||||||
|
}
|
||||||
|
|
||||||
$auditResults.CISControlVer = "v8"
|
$details = "OAuth2ClientProfileEnabled: $($orgConfig.OAuth2ClientProfileEnabled) for Organization: $($orgConfig.Name)"
|
||||||
$auditResults.CISControl = "3.10"
|
|
||||||
$auditResults.CISDescription = "Encrypt Sensitive Data in Transit"
|
|
||||||
$auditResults.IG1 = $false # As per CIS Control v8 mapping for IG1
|
|
||||||
$auditResults.IG2 = $true # As per CIS Control v8 mapping for IG2
|
|
||||||
$auditResults.IG3 = $true # As per CIS Control v8 mapping for IG3
|
|
||||||
$auditResults.ELevel = "E3" # Based on your environment (E3, E5, etc.)
|
|
||||||
$auditResults.ProfileLevel = "L1"
|
|
||||||
$auditResults.Rec = "6.5.1"
|
|
||||||
$auditResults.RecDescription = "Ensure modern authentication for Exchange Online is enabled (Automated)"
|
|
||||||
$auditResults.Result = $orgConfig.OAuth2ClientProfileEnabled
|
|
||||||
$auditResults.Details = $auditResults.Details = $orgConfig.Name + " OAuth2ClientProfileEnabled: " + $orgConfig.OAuth2ClientProfileEnabled
|
|
||||||
$auditResults.FailureReason = if (-not $orgConfig.OAuth2ClientProfileEnabled) { "Modern authentication is disabled" } else { "N/A" }
|
|
||||||
$auditResults.Status = if ($orgConfig.OAuth2ClientProfileEnabled) { "Pass" } else { "Fail" }
|
|
||||||
|
|
||||||
|
# Create and populate the CISAuditResult object
|
||||||
|
$auditResult = [CISAuditResult]::new()
|
||||||
|
$auditResult.CISControlVer = "v8"
|
||||||
|
$auditResult.CISControl = "3.10"
|
||||||
|
$auditResult.CISDescription = "Encrypt Sensitive Data in Transit"
|
||||||
|
$auditResult.IG1 = $false # As per CIS Control v8 mapping for IG1
|
||||||
|
$auditResult.IG2 = $true # As per CIS Control v8 mapping for IG2
|
||||||
|
$auditResult.IG3 = $true # As per CIS Control v8 mapping for IG3
|
||||||
|
$auditResult.ELevel = "E3" # Based on your environment (E3, E5, etc.)
|
||||||
|
$auditResult.ProfileLevel = "L1"
|
||||||
|
$auditResult.Rec = "6.5.1"
|
||||||
|
$auditResult.RecDescription = "Ensure modern authentication for Exchange Online is enabled (Automated)"
|
||||||
|
$auditResult.Result = $orgConfig.OAuth2ClientProfileEnabled
|
||||||
|
$auditResult.Details = $details
|
||||||
|
$auditResult.FailureReason = $failureReasons
|
||||||
|
$auditResult.Status = if ($orgConfig.OAuth2ClientProfileEnabled) { "Pass" } else { "Fail" }
|
||||||
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@@ -43,12 +52,7 @@ function Test-ModernAuthExchangeOnline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
end {
|
end {
|
||||||
# Return auditResults
|
# Return the audit result
|
||||||
return $auditResults
|
return $auditResult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user