<# .SYNOPSIS Bölüm 03 · Adım 3.4 — 5 Kurumsal Intune Zero Trust Uç Nokta Politikası Dağıtımı .DESCRIPTION Microsoft Graph (Connect-MgGraph) üzerinden 5 temel Windows 11 Zero Trust politikasını oluşturup All Devices hedefine atar: 1. INT-COMP-01-Windows11-ZeroTrust-Baseline (Compliance -> CA11 sinyali) 2. INT-ENC-01-Windows11-BitLocker-XTS256 (Sessiz XTS-AES-256 + Entra ID anahtar yedekleme) 3. INT-SEC-01-Defender-ASR-Rules-Windows11 (13 ASR Kuralı + Network Protection) 4. INT-LAPS-01-Windows11-Entra-CloudLAPS (Entra ID LAPS: 30 gün / 16 karakter / 4 saat reset) 5. INT-BASE-01-Windows11-Firewall-SmartScreen-Hardening (Firewall + SmartScreen) .EXAMPLE pwsh -ExecutionPolicy Bypass -File "D:\Lab\Scripts\04-Deploy-Intune-ZeroTrust-Suite.ps1" #> param( [string]$TenantId, [string]$ClientId, [string]$CertificateThumbprint ) $ErrorActionPreference = 'Stop' if ($ClientId -and $CertificateThumbprint -and $TenantId) { Connect-MgGraph -ClientId $ClientId -TenantId $TenantId -CertificateThumbprint $CertificateThumbprint -NoWelcome } else { Connect-MgGraph -Scopes 'DeviceManagementConfiguration.ReadWrite.All','DeviceManagementManagedDevices.ReadWrite.All' -NoWelcome } $allDevicesTarget = @{ '@odata.type' = '#microsoft.graph.allDevicesAssignmentTarget' } function Set-Assign($uri) { $body = @{ assignments = @(@{ target = $allDevicesTarget }) } | ConvertTo-Json -Depth 6 Invoke-MgGraphRequest -Method POST -Uri $uri -Body $body -ContentType 'application/json' | Out-Null } Write-Host "[1/5] Windows 11 Compliance Policy (CA11 kaynağı)..." -ForegroundColor Cyan $compName = 'INT-COMP-01-Windows11-ZeroTrust-Baseline' $cMatch = (Invoke-MgGraphRequest -Method GET -Uri 'https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies?$select=id,displayName').value | Where-Object { $_.displayName -eq $compName } | Select-Object -First 1 if (-not $cMatch) { $cBody = @{ '@odata.type' = '#microsoft.graph.windows10CompliancePolicy'; displayName = $compName bitLockerEnabled = $true; secureBootEnabled = $true; codeIntegrityEnabled = $true; tpmRequired = $true osMinimumVersion = '10.0.22621'; defenderEnabled = $true; antivirusRequired = $true; antiSpywareRequired = $true rtpEnabled = $true; firewallEnabled = $true scheduledActionsForRule = @(@{ ruleName = 'PasswordRequired'; scheduledActionConfigurations = @(@{ actionType = 'block'; gracePeriodHours = 24; notificationTemplateId = '' }) }) } | ConvertTo-Json -Depth 8 $cMatch = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies' -Body $cBody -ContentType 'application/json' } Set-Assign "https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/$($cMatch.id)/assign" $existingCfg = (Invoke-MgGraphRequest -Method GET -Uri 'https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$select=id,displayName').value Write-Host "[2/5] BitLocker Silent XTS-AES-256 + Entra ID Key Escrow..." -ForegroundColor Cyan $bitName = 'INT-ENC-01-Windows11-BitLocker-XTS256' $bMatch = $existingCfg | Where-Object { $_.displayName -eq $bitName } | Select-Object -First 1 if (-not $bMatch) { $bBody = @{ '@odata.type' = '#microsoft.graph.windows10EndpointProtectionConfiguration'; displayName = $bitName bitLockerEncryptDevice = $true; bitLockerDisableWarningForOtherDiskEncryption = $true; bitLockerAllowStandardUserEncryption = $true bitLockerRecoveryPasswordRotation = 'enabledForAzureAd' bitLockerSystemDrivePolicy = @{ encryptionMethod = 'xtsAes256'; startupAuthenticationRequired = $true; startupAuthenticationBlockWithoutTpmChip = $true startupAuthenticationTpmUsage = 'required'; startupAuthenticationTpmPinUsage = 'blocked'; startupAuthenticationTpmKeyUsage = 'blocked'; startupAuthenticationTpmPinAndKeyUsage = 'blocked' recoveryOptions = @{ blockDataRecoveryAgent = $false; recoveryPasswordUsage = 'required'; recoveryKeyUsage = 'allowed'; hideRecoveryOptions = $true; enableRecoveryInformationSaveToStore = $true; recoveryInformationToStore = 'passwordAndKey'; enableBitLockerAfterRecoveryInformationToStore = $true } } } | ConvertTo-Json -Depth 8 $bMatch = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations' -Body $bBody -ContentType 'application/json' } Set-Assign "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations/$($bMatch.id)/assign" Write-Host "[3/5] Defender ASR Rules (13 Kural + Network Protection)..." -ForegroundColor Cyan $asrName = 'INT-SEC-01-Defender-ASR-Rules-Windows11' $aMatch = $existingCfg | Where-Object { $_.displayName -eq $asrName } | Select-Object -First 1 if (-not $aMatch) { $aBody = @{ '@odata.type' = '#microsoft.graph.windows10EndpointProtectionConfiguration'; displayName = $asrName defenderBlockExecutableContentFromEmailAndWebmail = 'block'; defenderBlockOfficeApplicationsFromCreatingChildProcesses = 'block' defenderBlockOfficeApplicationsFromCreatingExecutableContent = 'block'; defenderBlockOfficeApplicationsFromInjectingCodeIntoOtherProcesses = 'block' defenderBlockJavaScriptOrVBScriptFromLaunchingDownloadedExecutableContent = 'block'; defenderBlockExecutionOfPotentiallyObfuscatedScripts = 'block' defenderBlockWin32ApiCallsFromOfficeMacros = 'block'; defenderBlockExecutableFilesRunningUnlessTheyMeetCriteria = 'auditMode' defenderUseAdvancedProtectionAgainstRansomware = 'block'; defenderBlockCredentialStealingFromWindowsLocalSecurityAuthoritySubsystem = 'block' defenderBlockUntrustedAndUnsignedProcessesThatRunFromUsb = 'auditMode'; defenderBlockAdobeReaderFromCreatingChildProcesses = 'block' defenderBlockPersistenceThroughWmiEventSubscription = 'block'; defenderPreventUsersAndAppsFromAccessingDangerousWebsites = 'enable' } | ConvertTo-Json -Depth 8 $aMatch = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/beta/deviceManagement/deviceConfigurations' -Body $aBody -ContentType 'application/json' } Set-Assign "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations/$($aMatch.id)/assign" Write-Host "[4/5] Microsoft Entra Cloud LAPS (Settings Catalog)..." -ForegroundColor Cyan $lapsName = 'INT-LAPS-01-Windows11-Entra-CloudLAPS' $lMatch = (Invoke-MgGraphRequest -Method GET -Uri 'https://graph.microsoft.com/beta/deviceManagement/configurationPolicies?$select=id,name').value | Where-Object { $_.name -eq $lapsName } | Select-Object -First 1 if (-not $lMatch) { $lBody = @{ name = $lapsName; platforms = 'windows10'; technologies = 'mdm'; templateReference = @{ templateId = '' } settings = @( @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting'; settingInstance = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance'; settingDefinitionId = 'device_vendor_msft_laps_policies_backupdirectory'; choiceSettingValue = @{ value = 'device_vendor_msft_laps_policies_backupdirectory_1'; children = @() } } }, @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting'; settingInstance = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance'; settingDefinitionId = 'device_vendor_msft_laps_policies_passwordagedays_aad'; simpleSettingValue = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue'; value = 30 } } }, @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting'; settingInstance = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance'; settingDefinitionId = 'device_vendor_msft_laps_policies_passwordcomplexity'; choiceSettingValue = @{ value = 'device_vendor_msft_laps_policies_passwordcomplexity_4'; children = @() } } }, @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting'; settingInstance = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance'; settingDefinitionId = 'device_vendor_msft_laps_policies_passwordlength'; simpleSettingValue = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue'; value = 16 } } }, @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting'; settingInstance = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance'; settingDefinitionId = 'device_vendor_msft_laps_policies_postauthenticationactions'; choiceSettingValue = @{ value = 'device_vendor_msft_laps_policies_postauthenticationactions_3'; children = @() } } }, @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSetting'; settingInstance = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance'; settingDefinitionId = 'device_vendor_msft_laps_policies_postauthenticationresetdelay'; simpleSettingValue = @{ '@odata.type' = '#microsoft.graph.deviceManagementConfigurationIntegerSettingValue'; value = 4 } } } ) } | ConvertTo-Json -Depth 12 $lMatch = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/beta/deviceManagement/configurationPolicies' -Body $lBody -ContentType 'application/json' } Set-Assign "https://graph.microsoft.com/beta/deviceManagement/configurationPolicies/$($lMatch.id)/assign" Write-Host "[5/5] Firewall & SmartScreen Baseline..." -ForegroundColor Cyan $fwName = 'INT-BASE-01-Windows11-Firewall-SmartScreen-Hardening' $fMatch = $existingCfg | Where-Object { $_.displayName -eq $fwName } | Select-Object -First 1 if (-not $fMatch) { $fBody = @{ '@odata.type' = '#microsoft.graph.windows10EndpointProtectionConfiguration'; displayName = $fwName firewallBlockStatefulFTP = $true; smartScreenEnableInShell = $true; smartScreenBlockOverrideForFiles = $true firewallProfileDomain = @{ firewallEnabled = 'allowed'; stealthModeBlocked = $false; incomingTrafficBlocked = $true; outboundConnectionsBlocked = $false } firewallProfilePrivate = @{ firewallEnabled = 'allowed'; stealthModeBlocked = $false; incomingTrafficBlocked = $true; outboundConnectionsBlocked = $false } firewallProfilePublic = @{ firewallEnabled = 'allowed'; stealthModeBlocked = $false; incomingTrafficBlocked = $true; outboundConnectionsBlocked = $false } } | ConvertTo-Json -Depth 8 $fMatch = Invoke-MgGraphRequest -Method POST -Uri 'https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations' -Body $fBody -ContentType 'application/json' } Set-Assign "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations/$($fMatch.id)/assign" Write-Host "[+] 5/5 Intune Zero Trust Uç Nokta Politikası All Devices hedefine atandı." -ForegroundColor Green