SHELL/8.5.9.ps1

$CheckId = "8.5.9"
$Title = "Ensure meeting recording is off by default"
$Level = "L2"
$BenchmarkType = "Automated"

try {
    $Policy = Get-CsTeamsMeetingPolicy -Identity Global -ErrorAction Stop
    $AllowCloudRecording = [bool]$Policy.AllowCloudRecording

    $Pass = -not $AllowCloudRecording
    $Status = if ($Pass) { "PASS" } else { "FAIL" }

    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = $Status
        Pass = $Pass
        Evidence = [pscustomobject]@{
            AllowCloudRecording = $AllowCloudRecording
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = if ($Pass) { $null } else { "AllowCloudRecording is True. It must be False on the Global meeting policy." }
        Timestamp = Get-Date
    }
}
catch {
    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = "ERROR"
        Pass = $null
        Evidence = [pscustomobject]@{ SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1" }
        Error = $_.Exception.Message
        Timestamp = Get-Date
    }
}