<# .SYNOPSIS TenantBrief Multi-Framework Quick-Wins — ORCA, EIDSCA, CIS M365 v7.0.0 & CISA SCuBA .DESCRIPTION Kod Güvenlik Sınıfı : Üretim ortamında uygulanabilir değişiklik (EXO + Microsoft Graph / Intune) Yetki Gereksinimi : Global Administrator / Security Admin + Exchange Admin + Intune Admin Ön Koşul : ExchangeOnlineManagement v3.9+ ve Azure CLI (az login) veya Microsoft.Graph Kapsanan TenantBrief Bulguları: - ORCA-240 : ExternalInOutlook (Harici gönderici etiketi) = True - 41029 (ORCA/CIS): Anti-Malware Default Policy (FileFilter=True, ZAP=True, Admin Notification) - ORCA-103 : Outbound Spam Rate Limits (500/1000/1000) & BccSuspiciousOutboundMail=True - CIS.M365.4.1 : Intune secureByDefault = True (Politikasız cihazlar Non-Compliant) - EIDSCA.AP05 : allowedToSignUpEmailBasedSubscriptions = False - 21954 (CIS) : allowedToReadBitlockerKeysForOwnedDevice = False - SCUBA-MS.AAD.3.5: Email OTP Authentication Method = Disabled - 21802 / 21841 : Authenticator App/Location Context + Report Suspicious Activity = Enabled - EIDSCA.AT02 : Temporary Access Pass isUsableOnce = True .EXAMPLE pwsh -ExecutionPolicy Bypass -File "D:\Lab\Scripts\03-Apply-TenantBrief-QuickWins.ps1" -AdminUpn "admin@contoso.onmicrosoft.com" -NotifyRecipient "admin@contoso.onmicrosoft.com" #> [CmdletBinding(SupportsShouldProcess = $true)] param( [string]$AdminUpn, [string]$AppId, [string]$CertificateThumbprint, [string]$Organization, [Parameter(Mandatory = $true)] [string]$NotifyRecipient, [switch]$SkipGraph ) $ErrorActionPreference = 'Stop' # --- A. EXCHANGE ONLINE / ORCA HARDENING --- Import-Module ExchangeOnlineManagement -ErrorAction Stop if ($AppId -and $CertificateThumbprint -and $Organization) { Write-Host "[1/4] Exchange Online sertifikalı oturum açılıyor ($Organization)..." -ForegroundColor Cyan Connect-ExchangeOnline -AppId $AppId -CertificateThumbprint $CertificateThumbprint -Organization $Organization -ShowBanner:$false } elseif ($AdminUpn) { Write-Host "[1/4] Exchange Online etkileşimli oturum açılıyor ($AdminUpn)..." -ForegroundColor Cyan Connect-ExchangeOnline -UserPrincipalName $AdminUpn -ShowBanner:$false } else { throw "AdminUpn veya (AppId + CertificateThumbprint + Organization) gereklidir." } if ($PSCmdlet.ShouldProcess("Exchange Online ORCA", "Apply ORCA-240, 41029 Anti-Malware, ORCA-103 Outbound Limits")) { Write-Host "[2/4] ORCA-240 (ExternalInOutlook), 41029 (Anti-Malware) ve ORCA-103 (Outbound Limits) uygulanıyor..." -ForegroundColor Cyan Set-ExternalInOutlook -Enabled $true Set-MalwareFilterPolicy -Identity 'Default' ` -EnableFileFilter $true ` -ZapEnabled $true ` -EnableInternalSenderAdminNotifications $true ` -InternalSenderAdminAddress $NotifyRecipient Set-HostedOutboundSpamFilterPolicy -Identity 'Default' ` -RecipientLimitExternalPerHour 500 ` -RecipientLimitInternalPerHour 1000 ` -RecipientLimitPerDay 1000 ` -BccSuspiciousOutboundMail $true ` -BccSuspiciousOutboundAdditionalRecipients @($NotifyRecipient) } Write-Host "`n--- EXO / ORCA Canlı Doğrulama ---" -ForegroundColor Green [pscustomobject]@{ ExternalInOutlook = (Get-ExternalInOutlook).Enabled MalwareFileFilter = (Get-MalwareFilterPolicy -Identity 'Default').EnableFileFilter MalwareZAP = (Get-MalwareFilterPolicy -Identity 'Default').ZapEnabled OutboundExtLimit = (Get-HostedOutboundSpamFilterPolicy -Identity 'Default').RecipientLimitExternalPerHour OutboundBccAlert = (Get-HostedOutboundSpamFilterPolicy -Identity 'Default').BccSuspiciousOutboundMail } | Format-List Disconnect-ExchangeOnline -Confirm:$false # --- B. MICROSOFT GRAPH (INTUNE CIS.M365.4.1 + ENTRA EIDSCA/SCUBA) --- if (-not $SkipGraph) { Write-Host "[3/4] Intune secureByDefault (CIS.M365.4.1) ve Entra EIDSCA/SCuBA sıkılaştırmaları uygulanıyor..." -ForegroundColor Cyan $graphToken = az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv 2>$null if (-not $graphToken) { Write-Warning "Azure CLI Graph jetonu alınamadı (az login gerekli); Graph bölümü atlandı." return } $headers = @{ Authorization = "Bearer $graphToken"; 'Content-Type' = 'application/json' } # 1. CIS.M365.4.1: Mark devices with no compliance policy assigned as Non-Compliant try { $bodyIntune = @{ settings = @{ secureByDefault = $true } } | ConvertTo-Json -Depth 4 Invoke-RestMethod -Method PATCH -Uri 'https://graph.microsoft.com/v1.0/deviceManagement' -Headers $headers -Body $bodyIntune | Out-Null Write-Host " [OK] CIS.M365.4.1 -> Intune secureByDefault = true" -ForegroundColor Green } catch { Write-Warning " [WARN] Intune secureByDefault: $($_.Exception.Message)" } # 2. EIDSCA.AP05 & CIS 21954: Block email-based signup & non-admin BitLocker key recovery try { $bodyAuthz = @{ allowedToSignUpEmailBasedSubscriptions = $false defaultUserRolePermissions = @{ allowedToReadBitlockerKeysForOwnedDevice = $false } } | ConvertTo-Json -Depth 4 Invoke-RestMethod -Method PATCH -Uri 'https://graph.microsoft.com/v1.0/policies/authorizationPolicy' -Headers $headers -Body $bodyAuthz | Out-Null Write-Host " [OK] EIDSCA.AP05 + 21954 -> EmailBasedSignup=False, NonAdminBitLockerRecovery=False" -ForegroundColor Green } catch { Write-Warning " [WARN] AuthorizationPolicy: $($_.Exception.Message)" } # 3. SCUBA-MS.AAD.3.5v2: Disable Email OTP try { $bodyEmail = @{ '@odata.type' = '#microsoft.graph.emailAuthenticationMethodConfiguration'; state = 'disabled' } | ConvertTo-Json Invoke-RestMethod -Method PATCH -Uri 'https://graph.microsoft.com/v1.0/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/Email' -Headers $headers -Body $bodyEmail | Out-Null Write-Host " [OK] SCUBA-MS.AAD.3.5v2 -> Email OTP = disabled" -ForegroundColor Green } catch { Write-Warning " [WARN] Email OTP: $($_.Exception.Message)" } # 4. EIDSCA.AT02: Temporary Access Pass -> isUsableOnce = true try { $bodyTap = @{ '@odata.type' = '#microsoft.graph.temporaryAccessPassAuthenticationMethodConfiguration'; isUsableOnce = $true } | ConvertTo-Json Invoke-RestMethod -Method PATCH -Uri 'https://graph.microsoft.com/v1.0/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/TemporaryAccessPass' -Headers $headers -Body $bodyTap | Out-Null Write-Host " [OK] EIDSCA.AT02 -> TemporaryAccessPass isUsableOnce = true" -ForegroundColor Green } catch { Write-Warning " [WARN] TAP: $($_.Exception.Message)" } # 5. 21802 & 21841: Microsoft Authenticator App/Location Context + Report Suspicious Activity try { $bodyAuth = @{ '@odata.type' = '#microsoft.graph.microsoftAuthenticatorAuthenticationMethodConfiguration' featureSettings = @{ displayAppInformationRequiredState = @{ state = 'enabled'; includeTarget = @{ targetType = 'group'; id = 'all_users' } } displayLocationInformationRequiredState = @{ state = 'enabled'; includeTarget = @{ targetType = 'group'; id = 'all_users' } } numberMatchingRequiredState = @{ state = 'enabled'; includeTarget = @{ targetType = 'group'; id = 'all_users' } } } } | ConvertTo-Json -Depth 6 Invoke-RestMethod -Method PATCH -Uri 'https://graph.microsoft.com/v1.0/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/MicrosoftAuthenticator' -Headers $headers -Body $bodyAuth | Out-Null $bodyReport = @{ reportSuspiciousActivitySettings = @{ state = 'enabled' voiceReportingCode = 0 includeTarget = @{ targetType = 'group'; id = 'all_users' } } } | ConvertTo-Json -Depth 5 Invoke-RestMethod -Method PATCH -Uri 'https://graph.microsoft.com/v1.0/policies/authenticationMethodsPolicy' -Headers $headers -Body $bodyReport | Out-Null Write-Host " [OK] 21802 + 21841 -> Authenticator Context + Report Suspicious Activity = enabled" -ForegroundColor Green } catch { Write-Warning " [WARN] Authenticator/ReportSuspicious: $($_.Exception.Message)" } }