<# .SYNOPSIS Bölüm 05 · Adım 5.1 — 2026 Defender Deployment Tool ile 5 VM Filo Onboarding ve Etiketleme .DESCRIPTION security.microsoft.com -> Settings -> Endpoints -> Onboarding ekranından indirilen Defender Deployment Tool paketini PowerShell Direct ile tüm 5 VM'e kopyalar, tek seferlik -key değerini çalışma zamanında ister (dosyaya kaydetmez) ve Sense / OnboardingState doğrulaması yapar. .EXAMPLE powershell -ExecutionPolicy Bypass -File "D:\Lab\Scripts\01-Onboard-Fleet-DefenderXDR.ps1" #> #Requires -RunAsAdministrator param( [string]$DdtZipPath = "D:\Lab\ISOs\DefenderDeploymentTool_Onboard_onboard.zip", [string]$NetBIOS = "CORP" ) $ErrorActionPreference = 'Stop' if (-not (Test-Path $DdtZipPath)) { throw "Defender Deployment Tool paketi bulunamadı: $DdtZipPath. security.microsoft.com -> Settings -> Endpoints -> Onboarding ekranından indirin." } $DdtKey = Read-Host -Prompt "Defender Deployment Tool tek seferlik anahtarını (-key) girin" $DomainCred = Get-Credential -UserName "$NetBIOS\Administrator" -Message "Domain VM'leri (DC01/SYNC01/MECM01/WIN11-01) yetkisi" $LocalCred = Get-Credential -UserName "Administrator" -Message "Cloud-Native WIN11-02 yerel Administrator yetkisi" $Fleet = @( @{ Name = 'DC01'; Tag = 'Lab-Tier0-DC'; Cred = $DomainCred }, @{ Name = 'SYNC01'; Tag = 'Lab-Tier0-IdentitySync'; Cred = $DomainCred }, @{ Name = 'MECM01'; Tag = 'Lab-Mgmt-MECM'; Cred = $DomainCred }, @{ Name = 'WIN11-01'; Tag = 'Lab-Hybrid-CoManaged'; Cred = $DomainCred }, @{ Name = 'WIN11-02'; Tag = 'Lab-CloudNative-Intune'; Cred = $LocalCred } ) $extractDir = Join-Path $env:TEMP 'DDT_Extract' Remove-Item $extractDir -Recurse -Force -ErrorAction SilentlyContinue Expand-Archive -Path $DdtZipPath -DestinationPath $extractDir -Force $ddtExe = Get-ChildItem $extractDir -Filter '*.exe' -Recurse | Select-Object -First 1 if (-not $ddtExe) { throw "ZIP içinde Defender Deployment Tool .exe bulunamadı." } $results = foreach ($node in $Fleet) { Write-Host "[*] Onboarding: $($node.Name) -> Tag: $($node.Tag)" -ForegroundColor Cyan $s = New-PSSession -VMName $node.Name -Credential $node.Cred try { Invoke-Command -Session $s -ScriptBlock { New-Item -Path 'C:\Temp\DDT' -ItemType Directory -Force | Out-Null } Copy-Item -Path $ddtExe.FullName -Destination 'C:\Temp\DDT\ddt.exe' -ToSession $s -Force Invoke-Command -Session $s -ArgumentList $DdtKey, $node.Tag -ScriptBlock { param($k, $t) Start-Process -FilePath 'C:\Temp\DDT\ddt.exe' -ArgumentList "-quiet -key:$k -devicetag:$t" -Wait -NoNewWindow Start-Sleep -Seconds 10 Remove-Item 'C:\Temp\DDT' -Recurse -Force -ErrorAction SilentlyContinue [pscustomobject]@{ Host = $env:COMPUTERNAME Sense = (Get-Service -Name 'Sense').Status OnboardingState = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status' -ErrorAction SilentlyContinue).OnboardingState DeviceTag = (Get-ItemProperty 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection\DeviceTagging' -ErrorAction SilentlyContinue).Group RealTimeProtect = (Get-MpComputerStatus).RealTimeProtectionEnabled } } } finally { Remove-PSSession $s -ErrorAction SilentlyContinue } } Remove-Item $extractDir -Recurse -Force -ErrorAction SilentlyContinue $results | Format-Table Host, Sense, OnboardingState, DeviceTag, RealTimeProtect -AutoSize