SHELL/6.5.3.ps1

$CheckId = "6.5.3"
$Title = "Ensure additional storage providers are restricted in Outlook on the web"
$Level = "L2"
$BenchmarkType = "Automated"

try {
    $Policy = Get-OwaMailboxPolicy -Identity OwaMailboxPolicy-Default -ErrorAction Stop
    $AdditionalStorageProvidersAvailable = [bool]$Policy.AdditionalStorageProvidersAvailable

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

    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = $Status
        Pass = $Pass
        Evidence = [pscustomobject]@{
            Identity = [string]$Policy.Identity
            AdditionalStorageProvidersAvailable = $AdditionalStorageProvidersAvailable
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = if ($Pass) { $null } else { "AdditionalStorageProvidersAvailable is True. It must be False." }
        Timestamp = Get-Date
    }
}
catch {
    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = "ERROR"
        Pass = $null
        Evidence = [pscustomobject]@{
            PolicyIdentity = "OwaMailboxPolicy-Default"
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = $_.Exception.Message
        Timestamp = Get-Date
    }
}