From 776b0bf2ecd214da85cb7dd39d0acd8e3ea3e6c4 Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Tue, 28 May 2024 13:12:38 -0500 Subject: [PATCH] fix: 8.5.3 aligned with test-template --- source/tests/Test-OrgOnlyBypassLobby.ps1 | 45 ++++++++++++++++-------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/source/tests/Test-OrgOnlyBypassLobby.ps1 b/source/tests/Test-OrgOnlyBypassLobby.ps1 index 013fe6d..4a2b5be 100644 --- a/source/tests/Test-OrgOnlyBypassLobby.ps1 +++ b/source/tests/Test-OrgOnlyBypassLobby.ps1 @@ -1,13 +1,14 @@ function Test-OrgOnlyBypassLobby { [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 { @@ -15,31 +16,45 @@ function Test-OrgOnlyBypassLobby { # Connect to Teams PowerShell using Connect-MicrosoftTeams + # Retrieve the Teams meeting policy for lobby bypass settings $CsTeamsMeetingPolicyLobby = Get-CsTeamsMeetingPolicy -Identity Global | Select-Object -Property AutoAdmittedUsers $lobbyBypassRestricted = $CsTeamsMeetingPolicyLobby.AutoAdmittedUsers -eq 'EveryoneInCompanyExcludingGuests' - # Create an instance of CISAuditResult and populate it + # Prepare failure reasons and details based on compliance + $failureReasons = if (-not $lobbyBypassRestricted) { + "External participants can bypass the lobby" + } + else { + "N/A" + } + + $details = if ($lobbyBypassRestricted) { + "Only people in the organization can bypass the lobby." + } + else { + "AutoAdmittedUsers is set to $($CsTeamsMeetingPolicyLobby.AutoAdmittedUsers)" + } + + # Create and populate the CISAuditResult object $auditResult = [CISAuditResult]::new() + $auditResult.Status = if ($lobbyBypassRestricted) { "Pass" } else { "Fail" } + $auditResult.ELevel = "E3" + $auditResult.ProfileLevel = "L1" + $auditResult.Rec = "8.5.3" + $auditResult.RecDescription = "Ensure only people in my org can bypass the lobby" $auditResult.CISControlVer = "v8" $auditResult.CISControl = "6.8" $auditResult.CISDescription = "Define and Maintain Role-Based Access Control" - $auditResult.Rec = "8.5.3" - $auditResult.ELevel = "E3" - $auditResult.ProfileLevel = "L1" $auditResult.IG1 = $false # Set based on the CIS Controls image $auditResult.IG2 = $false # Set based on the CIS Controls image $auditResult.IG3 = $true # Set based on the CIS Controls image - $auditResult.RecDescription = "Ensure only people in my org can bypass the lobby" $auditResult.Result = $lobbyBypassRestricted - $auditResult.Details = "AutoAdmittedUsers is set to $($CsTeamsMeetingPolicyLobby.AutoAdmittedUsers)" - $auditResult.FailureReason = if ($lobbyBypassRestricted) { "N/A" } else { "External participants can bypass the lobby" } - $auditResult.Status = if ($lobbyBypassRestricted) { "Pass" } else { "Fail" } - - $auditResults += $auditResult + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons } end { - # Return auditResults - return $auditResults + # Return the audit result + return $auditResult } }