diff --git a/source/tests/Test-NoAnonymousMeetingStart.ps1 b/source/tests/Test-NoAnonymousMeetingStart.ps1 index 4d5a432..38a6b2d 100644 --- a/source/tests/Test-NoAnonymousMeetingStart.ps1 +++ b/source/tests/Test-NoAnonymousMeetingStart.ps1 @@ -1,13 +1,14 @@ function Test-NoAnonymousMeetingStart { [CmdletBinding()] param ( + # Aligned # Parameters can be defined here if needed ) begin { - # Dot source the class script - - $auditResults = @() + # Dot source the class script if necessary + #. .\source\Classes\CISAuditResult.ps1 + # Initialization code, if needed } process { @@ -18,7 +19,17 @@ function Test-NoAnonymousMeetingStart { $CsTeamsMeetingPolicyAnonymous = Get-CsTeamsMeetingPolicy -Identity Global | Select-Object -Property AllowAnonymousUsersToStartMeeting $anonymousStartDisabled = -not $CsTeamsMeetingPolicyAnonymous.AllowAnonymousUsersToStartMeeting - # Create an instance of CISAuditResult and populate it + # Prepare failure reasons and details based on compliance + $failureReasons = if ($anonymousStartDisabled) { + "N/A" + } + else { + "Anonymous users and dial-in callers can start a meeting" + } + + $details = "AllowAnonymousUsersToStartMeeting is set to $($CsTeamsMeetingPolicyAnonymous.AllowAnonymousUsersToStartMeeting)" + + # Create and populate the CISAuditResult object $auditResult = [CISAuditResult]::new() $auditResult.CISControlVer = "v8" $auditResult.CISControl = "0.0" # Explicitly Not Mapped as per the image provided @@ -31,15 +42,13 @@ function Test-NoAnonymousMeetingStart { $auditResult.IG3 = $false # Set based on the CIS Controls image $auditResult.RecDescription = "Ensure anonymous users and dial-in callers can't start a meeting" $auditResult.Result = $anonymousStartDisabled - $auditResult.Details = "AllowAnonymousUsersToStartMeeting is set to $($CsTeamsMeetingPolicyAnonymous.AllowAnonymousUsersToStartMeeting)" - $auditResult.FailureReason = if ($anonymousStartDisabled) { "N/A" } else { "Anonymous users and dial-in callers can start a meeting" } + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons $auditResult.Status = if ($anonymousStartDisabled) { "Pass" } else { "Fail" } - - $auditResults += $auditResult } end { - # Return auditResults - return $auditResults + # Return the audit result + return $auditResult } }