新增 Setup.ps1(13 段 post-install);FirstLogonCommands 改從 Ventoy USB 拷腳本
把分散在 unattend.xml inline 的網路相依步驟(OpenSSH/Telegram/RemoveAI)和 新加入的 10 個 post-install 動作整合進獨立的 Setup.ps1,由 FirstLogonCommands Order 4 從 Ventoy USB(/ventoy/script/Setup.ps1)掃磁碟複製到 C:\Scripts\, Order 5 執行。腳本分兩 phase: Phase 1(不需網路):SSH 22 防火牆、RDP+3389、ICMP Echo、WinRM TrustedHosts=*、 移 OneDrive、關 Cortana/WebSearch、套 UI/IME 預設到 Default profile、user→User 改名 + 從登入畫面隱藏 Admin。 Phase 2(要網路,wait-network 後):OpenSSH Server FoD、KMS 啟用(先試 $InternalKmsServers 後 fallback 公開 KMS)、winget Chrome、RemoveWindowsAI、 Win11Debloat、22 個 UWP 移除、Telegram、刪 Panther 殘留。 每段以 Section 包裝寫獨立 START/DONE/ERR 到 C:\Windows\Temp\setup.log,方便逐段 重跑與排查。 文件全部同步:DEPLOY/QUICKSTART/SUMMARY/README/CLAUDE 都加上 Setup.ps1 的 USB 部署、cp 步驟、Order 表、排查指引。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
42
README.md
42
README.md
@@ -8,8 +8,11 @@
|
||||
|
||||
| 檔案 | 用途 |
|
||||
|---|---|
|
||||
| `unattend.xml` | 主回應檔,放入 USB/ISO 時需改名為 `autounattend.xml` |
|
||||
| `unattend.xml` | 主回應檔,部署到 Ventoy USB 的 `/ventoy/script/unattend.xml`(**不**改名為 `autounattend.xml`,Ventoy Auto Install plugin 走 `ventoy.json` 注入) |
|
||||
| `Setup.ps1` | 首次登入後的 post-install PowerShell;部署到 USB 的 `/ventoy/script/Setup.ps1`,FirstLogonCommands 會掃磁碟自動複製到 `C:\Scripts\` 後執行 |
|
||||
| `ventoy.json` | Ventoy Auto Install plugin 設定,把 ISO 對到 `unattend.xml` |
|
||||
| `QUICKSTART.md` | 操作步驟:如何產生 USB、掛載 ISO、跑 VM 測試 |
|
||||
| `DEPLOY.md` | 本機 USB 實機部署紀錄+ FirstLogonCommands / Setup.ps1 詳細排查 |
|
||||
| `SUMMARY.md` | 本專案的來由與設計脈絡 |
|
||||
|
||||
---
|
||||
@@ -42,7 +45,7 @@ Windows Setup 在不同階段套用不同 `<settings pass="...">`:
|
||||
### specialize
|
||||
|
||||
- **Microsoft-Windows-Shell-Setup**
|
||||
- `ComputerName` — `PC-%RAND:5%`(5 位隨機數字)
|
||||
- `ComputerName` — `*`(Setup 自動產生隨機名,`FirstLogonCommands` 再用 `Rename-Computer` 改成 `PC-XXXXX`,重開後生效)。**不可寫 `PC-%RAND:5%`**——那是 MDT/SCCM 變數,直接放這裡會被當字面字串送進 NetBIOS 驗證而失敗
|
||||
- `TimeZone` — `Taipei Standard Time`
|
||||
- `RegisteredOwner` / `RegisteredOrganization`
|
||||
|
||||
@@ -54,13 +57,18 @@ Windows Setup 在不同階段套用不同 `<settings pass="...">`:
|
||||
- `UserAccounts.LocalAccounts` — 建立 `Admin`(Administrators 群組,密碼 `P@ssw0rd!`,明碼)
|
||||
- `AutoLogon` — 以 `Admin` 自動登入一次(`LogonCount=1`)
|
||||
- `FirstLogonCommands` — 按 `Order` 依序執行:
|
||||
1. `powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\Setup.ps1`
|
||||
2. `cmd.exe /c net accounts /maxpwage:unlimited`(密碼永不過期)
|
||||
3. `Rename-Computer` 改主機名成 `PC-XXXXX`(重開後生效)
|
||||
4. 建立本機帳號 `user`(密碼 `1234`,`net user /logonpasswordchg:yes` 強制首次登入改密)
|
||||
5. 等網路→`Add-WindowsCapability OpenSSH.Server` 安裝並 `Set-Service sshd Automatic` / `Start-Service sshd`(log 寫到 `C:\Windows\Temp\firstlogon-sshd.log`)
|
||||
6. 等網路→下載 `https://telegram.org/dl/desktop/win64` 並以 `/VERYSILENT /SUPPRESSMSGBOXES /NORESTART` 靜默安裝 Telegram(log 寫到 `C:\Windows\Temp\firstlogon-telegram.log`)
|
||||
7. `shutdown /r /t 5`(重開機)
|
||||
1. `cmd.exe /c net accounts /maxpwage:unlimited`(密碼永不過期)
|
||||
2. `Rename-Computer` 改主機名成 `PC-XXXXX`(重開後生效)
|
||||
3. 建立本機帳號 `user`(密碼 `1234`,`net user /logonpasswordchg:yes` 強制首次登入改密;之後 `Setup.ps1` 會把它改名成 `User`)
|
||||
4. 掃所有掛載中的 FileSystem PSDrive 找 `\ventoy\script\Setup.ps1`,複製到 `C:\Scripts\Setup.ps1`(log 寫到 `C:\Windows\Temp\firstlogon-copysetup.log`)
|
||||
5. 跑 `C:\Scripts\Setup.ps1`(13 段 post-install 詳見 `Setup.ps1` 與 `DEPLOY.md`,log 寫到 `C:\Windows\Temp\setup.log`;找不到檔案時改寫 `firstlogon-runsetup.log` 並跳過)
|
||||
6. `shutdown /r /t 5`(重開機)
|
||||
|
||||
### `Setup.ps1` 涵蓋的 13 段(首次登入由 Order 5 執行)
|
||||
|
||||
**Phase 1(不需網路):** SSH 22/TCP 防火牆、RDP+3389、ICMP Echo Inbound、WinRM(`TrustedHosts=*`)、OneDrive 解除安裝、Cortana/Web Search 關閉、Default profile 套 Dark mode+顯示副檔名/隱藏檔+工作列靠左+預設英數鍵盤+停 IME 切換熱鍵、`user`→`User` 改名+從登入畫面隱藏 `Admin`。
|
||||
|
||||
**Phase 2(需網路,`wait-network` 後執行):** OpenSSH Server FoD、KMS 啟用(先試 `$InternalKmsServers` 再 fallback 公開 KMS)、winget 裝 Chrome、`zoicware/RemoveWindowsAI -AllOptions`、`Raphire/Win11Debloat -Silent -Config`、22 個 UWP AppxPackage 移除(與 `windows-remote-toolkit/config/remove-apps-config.json` 同步)、Telegram 靜默安裝、刪 `C:\Windows\Panther\unattend.xml` 殘留。
|
||||
|
||||
---
|
||||
|
||||
@@ -82,10 +90,10 @@ Windows Setup 在不同階段套用不同 `<settings pass="...">`:
|
||||
|
||||
| 方式 | 位置 | 檔名 |
|
||||
|---|---|---|
|
||||
| **Ventoy Auto Install plugin(本 repo 預設)** | Ventoy USB 的 `/ventoy/script/`,並在 `/ventoy/ventoy.json` 指定 | 任意(本 repo 用 `unattend.xml`) |
|
||||
| 傳統 USB 安裝碟 | USB 根目錄 | `autounattend.xml` |
|
||||
| ISO `sources\` 目錄 | ISO 根 | `autounattend.xml` |
|
||||
| DISM 離線注入已掛載映像 | — | 任意名稱,用 `/Apply-Unattend:` 指定 |
|
||||
| **Ventoy Auto Install plugin(本 repo 預設)** | Ventoy USB 的 `/ventoy/script/unattend.xml`+`/ventoy/script/Setup.ps1`,並在 `/ventoy/ventoy.json` 指定 | 任意(本 repo 用 `unattend.xml`) |
|
||||
| 傳統 USB 安裝碟 | USB 根目錄 | `autounattend.xml`(注意:FirstLogonCommands Order 4 的磁碟掃描還是會找 `\ventoy\script\Setup.ps1`,要嘛把 `Setup.ps1` 放對位置,要嘛改 Order 4 的搜尋路徑) |
|
||||
| ISO `sources\` 目錄 | ISO 根 | `autounattend.xml`(同上) |
|
||||
| DISM 離線注入已掛載映像 | — | 任意名稱,用 `/Apply-Unattend:` 指定(這條路徑下 `Setup.ps1` 通常會直接烘進 image 而不再走 USB 掃描) |
|
||||
|
||||
---
|
||||
|
||||
@@ -99,11 +107,9 @@ Windows Setup 在不同階段套用不同 `<settings pass="...">`:
|
||||
## 安全性
|
||||
|
||||
- 本範本密碼為明碼,僅適合內網測試;生產環境請改 Base64 或交由 MDT/SCCM 管理。
|
||||
- 部署結束後應刪除殘留的 unattend 檔,例如在 `Setup.ps1` 尾端:
|
||||
```powershell
|
||||
Remove-Item C:\Windows\Panther\unattend.xml -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item C:\Windows\Panther\Unattend\unattend.xml -Force -ErrorAction SilentlyContinue
|
||||
```
|
||||
- `Setup.ps1` 的 `cleanup-unattend-files` 段已經會在收尾時刪掉 `C:\Windows\Panther\unattend.xml` 與 `Panther\Unattend\unattend.xml`(含明碼密碼)。
|
||||
- WinRM `AllowUnencrypted=true` + `TrustedHosts=*` 是測試環境設定;正式環境要改 HTTPS(5986)+ 限制 TrustedHosts。
|
||||
- KMS 預設 fallback 到第三方公開伺服器(`kms.digiboy.ir` 等);正式環境改 `Setup.ps1` 的 `$InternalKmsServers`。
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user