SHELL/7.2.10.ps1

$CheckId = "7.2.10"
$Title = "Ensure reauthentication with verification code is restricted"
$Level = "L1"
$BenchmarkType = "Automated"

try {
    $TenantConfig = Get-SPOTenant -ErrorAction Stop

    $EmailAttestationRequired = [bool]$TenantConfig.EmailAttestationRequired
    $EmailAttestationReAuthDays = [int]$TenantConfig.EmailAttestationReAuthDays

    $Pass = $EmailAttestationRequired -and ($EmailAttestationReAuthDays -le 15)
    $Status = if ($Pass) { "PASS" } else { "FAIL" }

    [pscustomobject]@{
        CheckId = $CheckId
        Title = $Title
        Level = $Level
        BenchmarkType = $BenchmarkType
        Status = $Status
        Pass = $Pass
        Evidence = [pscustomobject]@{
            EmailAttestationRequired = $EmailAttestationRequired
            EmailAttestationReAuthDays = $EmailAttestationReAuthDays
            SourceDocument = "CIS_Microsoft_365_Foundations_Benchmark_v6.0.1"
        }
        Error = if ($Pass) { $null } else { "EmailAttestationRequired must be True and EmailAttestationReAuthDays must be 15 or less." }
        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
    }
}