. "$PSScriptRoot\_common.ps1" Section 'win11debloat' { Wait-Network -timeoutSec 30 $work = Join-Path $env:TEMP 'win11debloat' $zip = "$work.zip" if (Test-Path $work) { Remove-Item $work -Recurse -Force } Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/Raphire/Win11Debloat/archive/refs/heads/master.zip' -OutFile $zip Expand-Archive -Path $zip -DestinationPath $work -Force $dir = Get-ChildItem $work -Directory | Select-Object -First 1 if (-not $dir) { throw 'Win11Debloat zip extracted but no inner dir' } $cfgSrc = Join-Path $PSScriptRoot 'win11debloat-config.json' $cfgDst = Join-Path $dir.FullName 'unattend-config.json' Copy-Item $cfgSrc $cfgDst -Force # -Sysprep 讓 Win11Debloat 把所有 HKCU 設定寫到 Default profile 的 offline hive, # 避免 HKCU\SearchSettings 被 Search Indexer 鎖住造成 reg import 失敗, # 同時符合「Admin 會被隱藏、未來只有 User 登入」的部署模式 & "$($dir.FullName)\Win11Debloat.ps1" -Silent -Sysprep -Config $cfgDst -NoRestartExplorer }