SHELL/7.3.1.ps1

$CheckId = "7.3.1"
$Title = "Ensure Office 365 SharePoint infected files are disallowed for download"
$Level = "L2"
$BenchmarkType = "Automated"

try {
    $TenantConfig = Get-SPOTenant -ErrorAction Stop
    $DisallowInfectedFileDownload = [bool]$TenantConfig.DisallowInfectedFileDownload

    $Pass = $DisallowInfectedFileDownload
    $Status = if ($Pass) { "PASS" } else { "FAIL" }

    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = $Status
        Pass = $Pass
        Evidence = [pscustomobject]@{
            DisallowInfectedFileDownload = $DisallowInfectedFileDownload
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = if ($Pass) { $null } else { "DisallowInfectedFileDownload is False. It must be True." }
        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
    }
}