SHELL/9.1.6.ps1

$CheckId = "9.1.6"
$Title = "Ensure 'Allow users to apply sensitivity labels for content' is 'Enabled'"
$Level = "L1"
$BenchmarkType = "Automated"
$SettingName = "EimInformationProtectionEdit"
$SettingTitle = "Allow users to apply sensitivity labels for content"
$HelperPath = Join-Path $PSScriptRoot "helpers\fabric_settings_helpers.ps1"
$AuditCommands = @(
    "Invoke-RestMethod -Uri 'https://api.fabric.microsoft.com/v1/admin/tenantsettings' -Method Get",
    "Find setting by settingName 'EimInformationProtectionEdit' or title 'Allow users to apply sensitivity labels for content'"
)

if (-not (Test-Path $HelperPath)) {
    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = "ERROR"
        Pass = $null
        Evidence = [pscustomobject]@{
            AuditCommands = $AuditCommands
            HelperPath = $HelperPath
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = "Required helper file not found: $HelperPath"
        Timestamp = Get-Date
    }
    return
}

. $HelperPath

Invoke-Root365FabricControl `
    -CheckId $CheckId `
    -Title $Title `
    -Level $Level `
    -BenchmarkType $BenchmarkType `
    -SettingName $SettingName `
    -SettingTitle $SettingTitle `
    -Mode "Enable" `
    -MissingSettingBehavior "Fail" `
    -AuditCommands $AuditCommands `
    -ExpectedStateDescription "Enabled."