diff --git a/source/tests/Test-MeetingChatNoAnonymous.ps1 b/source/tests/Test-MeetingChatNoAnonymous.ps1 index b75835a..5a6035a 100644 --- a/source/tests/Test-MeetingChatNoAnonymous.ps1 +++ b/source/tests/Test-MeetingChatNoAnonymous.ps1 @@ -1,25 +1,36 @@ function Test-MeetingChatNoAnonymous { [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 { # 8.5.5 (L2) Ensure meeting chat does not allow anonymous users - # Name doesn't match profile level in benchmarks either. # Connect to Teams PowerShell using Connect-MicrosoftTeams + # Retrieve the Teams meeting policy for meeting chat $CsTeamsMeetingPolicyChat = Get-CsTeamsMeetingPolicy -Identity Global | Select-Object -Property MeetingChatEnabledType $chatAnonDisabled = $CsTeamsMeetingPolicyChat.MeetingChatEnabledType -eq 'EnabledExceptAnonymous' - # Create an instance of CISAuditResult and populate it + # Prepare failure reasons and details based on compliance + $failureReasons = if ($chatAnonDisabled) { + "N/A" + } + else { + "Meeting chat allows anonymous users" + } + + $details = "MeetingChatEnabledType is set to $($CsTeamsMeetingPolicyChat.MeetingChatEnabledType)" + + # Create and populate the CISAuditResult object $auditResult = [CISAuditResult]::new() $auditResult.CISControlVer = "v8" $auditResult.CISControl = "0.0" # Explicitly Not Mapped as per the image provided @@ -32,15 +43,13 @@ function Test-MeetingChatNoAnonymous { $auditResult.IG3 = $false # Set based on the CIS Controls image $auditResult.RecDescription = "Ensure meeting chat does not allow anonymous users" $auditResult.Result = $chatAnonDisabled - $auditResult.Details = "MeetingChatEnabledType is set to $($CsTeamsMeetingPolicyChat.MeetingChatEnabledType)" - $auditResult.FailureReason = if ($chatAnonDisabled) { "N/A" } else { "Meeting chat allows anonymous users" } + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons $auditResult.Status = if ($chatAnonDisabled) { "Pass" } else { "Fail" } - - $auditResults += $auditResult } end { - # Return auditResults - return $auditResults + # Return the audit result + return $auditResult } }