第2季 · WS2022 · WDS

WDS 无人值守安装实战(WS2022新版)

【第2季第4篇】Windows Server 2022 WDS 无人值守安装:WS2022 镜像捕获与多系统选择菜单

系列:爱依航 · Windows Server 2022 运维系列

本篇主题:WDS 无人值守安装实战(WS2022 新版)

环境:WDS 服务器 IP 192.168.10.12


开篇:WS 2022 WDS 的改进

WS 2022 的 WDS 在功能上没有革命性变化,但有几个值得关注的改进:

对于需要同时管理服务器和桌面系统的 IT 环境,这是一个重要的升级理由。


Part 1 · WDS 基础部署(WS 2022)

安装 WDS 角色


Install-WindowsFeature -Name WDS -IncludeManagementTools

# 初始化 WDS
wdsutil /initialize-server /reminst:"D:\RemoteInstall"

WS 2022 与 WS 2019 WDS 的核心差异

对比项 WS 2019 WDS WS 2022 WDS
------- ------------ ------------
启动镜像 boot.wim (1809) boot.wim (21H2)
Windows PE 版本 PE 1803 PE 21H2
UEFI 支持 ✅(更完善)
多系统支持 WS 2016/2019 WS 2022 + Win11
Secure Boot 支持

Part 2 · 添加 WS 2022 安装镜像


# 添加启动镜像(从 WS 2022 ISO sources\boot.wim)
Import-WdsBootImage `
  -ImagePath "D:\RemoteInstall\Images\WS2022\boot.wim" `
  -ImageName "Windows Server 2022 Boot Image" `
  -NewImageName "WS2022 x64 Boot" `
  -UnattendFile "D:\RemoteInstall\WdsClientUnattend\Autounattend.xml"

# 添加安装镜像组
Add-WdsInstallImageGroup -Name "WS2022-Server"

# 从 install.wim 导入(WS 2022 ISO sources\install.wim)
Import-WdsInstallImage `
  -ImagePath "D:\RemoteInstall\Images\WS2022\install.wim" `
  -ImageGroup "WS2022-Server" `
  -FileName "install.wim"

多系统镜像组(WS 2022 + WS 2019 + Win11)


# 创建多系统镜像组
Add-WdsInstallImageGroup -Name "All-In-One"

# 导入各个镜像
Import-WdsInstallImage -ImagePath "D:\RemoteInstall\Images\WS2022\install.wim" `
  -ImageGroup "All-In-One" -FileName "install.wim"

Import-WdsInstallImage -ImagePath "D:\RemoteInstall\Images\WS2019\install.wim" `
  -ImageGroup "All-In-One" -FileName "install.wim"

Import-WdsInstallImage -ImagePath "D:\RemoteInstall\Images\Win11\install.wim" `
  -ImageGroup "All-In-One" -FileName "install.wim"

# 查看所有镜像
Get-WdsInstallImage -ImageGroup "All-In-One" | Select ImageName,ImageSize,Language

客户端 PXE 启动后,会显示一个选择列表,列出 All-In-One 组中的所有镜像。


Part 3 · WS 2022 应答文件关键差异

WS 2022 安装时需要使用服务器授权激活,KMS 激活环境请在应答文件中配置:


<!-- specialize 阶段添加 KMS 客户端安装密钥 -->
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" ...>
  <ProductKey>
    <Key>WXGM-NDMKT-BWMMK-3KG8C-2QTKG</Key>  <!-- WS 2022 Standard KMS -->
    <WillShowUI>Never</WillShowUI>
  </ProductKey>
</component>

<!-- 配置 KMS 服务器地址 -->
<component name="Microsoft-Windows-Security-SPP-UX" ...>
  <AutoLogin>
    <Password>YourPassword</Password>
    <LogonCount>1</LogonCount>
    <Username>Administrator</Username>
  </AutoLogin>
</component>

WS 2022 Datacenter 的 KMS 密钥:CB7KF-BWN84-R7R2Y-793K2-8XDDG


Part 4 · 常见故障

故障一:UEFI 模式下 PXE 失败

UEFI PXE 启动需要 bootx64.efi 文件,且 DHCP Option 60/66/67 配置方式不同。


# 查看 WDS 当前配置
Get-WdsServer | Select-Object BootProgramPath,Architecture

# UEFI x64 引导程序路径
Get-WdsBootImage -ImageId (Get-WdsBootImage).ImageId | Select-Object FileName,Architecture

# 如果 UEFI PXE 失败,检查 DHCP 是否同时提供 Option 66(boot server hostname)
# 不建议在 DHCP 上配置 Option 67;WDS 应通过标准 bootx64.efi 工作

故障二:引导镜像加载慢

通常是 boot.wim 体积大导致。建议定期精简引导镜像,只保留需要的驱动和组件:


# 重新捕获精简版 boot.wim(使用 DISM)
dism /Mount-Image /ImageFile:"D:\mount\boot.wim" /Index:1 /MountDir:"D:\mount\target"
dism /Image:"D:\mount\target" /ScratchDir:"D:\scratch" /Add-Drivers /Driver:"D:\drivers\storage" /Recurse
dism /Unmount-Image /MountDir:"D:\mount\target" /Commit

下期预告

第2季 Windows Server 2022 完成!

下期开始第3季:Windows Server 2025 —— 最新 LTS 版本,Active Directory 的重大升级来了。