SHELL/8.5.5.ps1

$CheckId = "8.5.5"
$Title = "Ensure meeting chat does not allow anonymous users"
$Level = "L2"
$BenchmarkType = "Automated"

$AllowedValues = @(
    "EnabledExceptAnonymous",
    "EnabledInMeetingOnlyForAllExceptAnonymous",
    "Disabled"
)

try {
    $Policy = Get-CsTeamsMeetingPolicy -Identity Global -ErrorAction Stop
    $MeetingChatEnabledType = [string]$Policy.MeetingChatEnabledType

    $Pass = $AllowedValues -contains $MeetingChatEnabledType
    $Status = if ($Pass) { "PASS" } else { "FAIL" }

    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = $Status
        Pass = $Pass
        Evidence = [pscustomobject]@{
            MeetingChatEnabledType = $MeetingChatEnabledType
            AllowedValues = $AllowedValues
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = if ($Pass) { $null } else { "MeetingChatEnabledType is '$MeetingChatEnabledType'. It must be EnabledExceptAnonymous, EnabledInMeetingOnlyForAllExceptAnonymous, or Disabled." }
        Timestamp = Get-Date
    }
}
catch {
    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = "ERROR"
        Pass = $null
        Evidence = [pscustomobject]@{ AllowedValues = $AllowedValues; SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1" }
        Error = $_.Exception.Message
        Timestamp = Get-Date
    }
}