<# .SYNOPSIS Microsoft Defender for Office 365 (MDO) Zero Trust Politikalarını Dağıtır. .DESCRIPTION Kod Güvenlik Sınıfı : Üretim ortamında uygulanabilir değişiklik (Exchange Online PowerShell) Yetki Gereksinimi : Security Administrator veya Exchange Administrator Ön Koşul : ExchangeOnlineManagement v3.9+ (PowerShell 7 önerilir) Oluşturulan politikalar: 1. Global Safe Attachments (SharePoint, OneDrive, Teams + Safe Documents) 2. MDO-01-SafeLinks-ZeroTrust (Email, Teams, Office 365 Apps + Click-Through Engeli) 3. MDO-02-SafeAttachments-DynamicDelivery (Dynamic Delivery + Bilinmeyen Zararlı Engeli) 4. MDO-03-AntiPhishing-ZeroTrust (More Aggressive Threshold 3 + Mailbox/Spoof Intelligence) .EXAMPLE pwsh -ExecutionPolicy Bypass -File "D:\Lab\Scripts\02-Deploy-MDO-ZeroTrust-Policies.ps1" -AdminUpn "admin@contoso.onmicrosoft.com" -AcceptedDomain "contoso.onmicrosoft.com" #> [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] [string]$AdminUpn, [Parameter(Mandatory = $true)] [string]$AcceptedDomain, [string[]]$ProtectedAdmins = @() ) $ErrorActionPreference = 'Stop' Import-Module ExchangeOnlineManagement -ErrorAction Stop Write-Host "[1/5] Exchange Online oturumu açılıyor ($AdminUpn)..." -ForegroundColor Cyan Connect-ExchangeOnline -UserPrincipalName $AdminUpn -ShowBanner:$false # 1. Global Safe Attachments for SharePoint, OneDrive, Teams & Safe Documents Write-Host "[2/5] Global Safe Attachments (SPO/ODB/Teams + Safe Documents) etkinleştiriliyor..." -ForegroundColor Cyan if ($PSCmdlet.ShouldProcess("AtpPolicyForO365", "Enable SharePoint/OneDrive/Teams scanning and Safe Documents")) { Set-AtpPolicyForO365 -EnableATPForSPOTeamsODB $true -EnableSafeDocs $true -AllowSafeDocsOpen $false } # 2. Safe Links Policy (MDO-01-SafeLinks-ZeroTrust) Write-Host "[3/5] MDO-01-SafeLinks-ZeroTrust yapılandırılıyor..." -ForegroundColor Cyan $slName = 'MDO-01-SafeLinks-ZeroTrust' if (-not (Get-SafeLinksPolicy -Identity $slName -ErrorAction SilentlyContinue)) { New-SafeLinksPolicy -Name $slName ` -EnableSafeLinksForEmail $true ` -EnableSafeLinksForTeams $true ` -EnableSafeLinksForOffice $true ` -TrackClicks $true ` -AllowClickThrough $false ` -ScanUrls $true ` -EnableForInternalSenders $true ` -DeliverMessageAfterScan $true ` -DisableUrlRewrite $false | Out-Null } if (-not (Get-SafeLinksRule -Identity "Rule-$slName" -ErrorAction SilentlyContinue)) { New-SafeLinksRule -Name "Rule-$slName" -SafeLinksPolicy $slName -RecipientDomainIs $AcceptedDomain -Enabled $true | Out-Null } # 3. Safe Attachments Policy (MDO-02-SafeAttachments-DynamicDelivery) Write-Host "[4/5] MDO-02-SafeAttachments-DynamicDelivery yapılandırılıyor..." -ForegroundColor Cyan $saName = 'MDO-02-SafeAttachments-DynamicDelivery' if (-not (Get-SafeAttachmentPolicy -Identity $saName -ErrorAction SilentlyContinue)) { New-SafeAttachmentPolicy -Name $saName -Enable $true -Action DynamicDelivery -QuarantineTag 'AdminOnlyAccessPolicy' | Out-Null } if (-not (Get-SafeAttachmentRule -Identity "Rule-$saName" -ErrorAction SilentlyContinue)) { New-SafeAttachmentRule -Name "Rule-$saName" -SafeAttachmentPolicy $saName -RecipientDomainIs $AcceptedDomain -Enabled $true | Out-Null } # 4. Anti-Phishing Policy (MDO-03-AntiPhishing-ZeroTrust) Write-Host "[5/5] MDO-03-AntiPhishing-ZeroTrust yapılandırılıyor..." -ForegroundColor Cyan $apName = 'MDO-03-AntiPhishing-ZeroTrust' if (-not (Get-AntiPhishPolicy -Identity $apName -ErrorAction SilentlyContinue)) { $apParams = @{ Name = $apName Enabled = $true PhishThresholdLevel = 3 EnableMailboxIntelligence = $true EnableMailboxIntelligenceProtection = $true MailboxIntelligenceProtectionAction = 'Quarantine' EnableSpoofIntelligence = $true AuthenticationFailAction = 'Quarantine' EnableOrganizationDomainsProtection = $true TargetedDomainProtectionAction = 'Quarantine' EnableFirstContactSafetyTips = $true EnableViaTag = $true EnableUnauthenticatedSender = $true HonorDmarcPolicy = $true } if ($ProtectedAdmins.Count -gt 0) { $apParams['EnableTargetedUserProtection'] = $true $apParams['TargetedUsersToProtect'] = $ProtectedAdmins $apParams['TargetedUserProtectionAction'] = 'Quarantine' } New-AntiPhishPolicy @apParams | Out-Null } if (-not (Get-AntiPhishRule -Identity "Rule-$apName" -ErrorAction SilentlyContinue)) { New-AntiPhishRule -Name "Rule-$apName" -AntiPhishPolicy $apName -RecipientDomainIs $AcceptedDomain -Enabled $true | Out-Null } Write-Host "`n--- Canlı Doğrulama Özeti (Salt Okunur) ---" -ForegroundColor Green Get-AtpPolicyForO365 | Select-Object EnableATPForSPOTeamsODB, EnableSafeDocs, AllowSafeDocsOpen | Format-Table -AutoSize Get-SafeLinksPolicy -Identity $slName | Select-Object Name, EnableSafeLinksForEmail, EnableSafeLinksForTeams, AllowClickThrough, DeliverMessageAfterScan | Format-Table -AutoSize Get-SafeAttachmentPolicy -Identity $saName | Select-Object Name, Enable, Action | Format-Table -AutoSize Get-AntiPhishPolicy -Identity $apName | Select-Object Name, Enabled, PhishThresholdLevel, EnableMailboxIntelligence, EnableSpoofIntelligence | Format-Table -AutoSize