🌐 Windows PXE 自动化部署环境搭建


✅ 一、环境准备与网络配置


🧾 步骤 1:配置服务器静态 IP(IPv4 和 IPv6)

  1. 控制面板 → 网络和共享中心 → 更改适配器设置

  2. 右键网络 → 属性 → 选择 IPv4IPv6 → 属性

  3. 示例配置:

    • IPv4:

      • IP 地址:192.168.10.1
      • 子网掩码:255.255.255.0
      • 默认网关:192.168.10.1
    • IPv6:

      • 地址:fd00:10::1
      • 前缀长度:64
      • 网关:fd00:10::1
  4. 点击”确定”保存


🧾 步骤 2:安装 DHCP 和 DNS 服务

  1. 打开 服务器管理器

  2. 点击”添加角色和功能”

  3. 选择:

    • ✅ DHCP Server(DHCP 服务器)
    • ✅ DNS Server(DNS 服务器)
  4. 一路”下一步”直到安装完成

  5. 安装完成后根据提示启动 DHCP 配置向导并完成设置


✅ 二、配置 DHCPv4 和 DHCPv6 服务


📌 步骤 3:配置 DHCPv4 服务

  1. 打开 DHCP 管理器

  2. 右键 IPv4 → 新建作用域

  3. 设置作用域信息:

    • 名称:Internal-Network
    • 范围:192.168.10.100 - 192.168.10.199
    • 排除:192.168.10.120 - 192.168.10.129
    • 子网掩码:255.255.255.0
    • 网关:192.168.10.1
    • DNS:192.168.10.1
  4. 激活作用域


📌 步骤 4:配置 DHCPv6 服务

  1. DHCP 管理器中 → IPv6 → 新建作用域

  2. 配置如下:

    • 名称:Internal-IPv6
    • 前缀:fd00:10::
    • 前缀长度:64
    • 范围编号:1 - 9999
  3. 完成并激活作用域


📌 步骤 5:启用 IPv6 Router Advertisement(RA)

命令行方式:

  1. 查询interface id

    1
    2
    3
    4
    5
    netsh interface ipv6 show interface

    Idx Met MTU State Name
    --- ---------- ---------- ------------ ---------------------------
    <interface id> 15 1500 connected Ethernet
  2. 启用 IPv6 转发和 RA 广播

    1
    2
    3
    4
    5
    netsh interface ipv6 set interface <interface id> forwarding=enabled
    netsh interface ipv6 set interface <interface id> advertised=enabled
    netsh interface ipv6 set interface <interface id> managedaddress=enabled
    netsh interface ipv6 set interface <interface id> otherstateful=enabled
    netsh interface ipv6 add route fd00:10::/64 <interface id> publish=enabled
  3. 检查状态

    1
    2
    3
    4
    5
    6
    7
    8
    9
    netsh interface ipv6 show interface <interface id>
    Forwarding : enabled
    Advertising : enabled
    Managed Address Configuration : enabled
    Other Stateful Configuration : enabled

    netsh interface ipv6 show addresses <interface id>
    Public Preferred 29d23h56m28s 6d23h56m28s fd00:10::100
    Dhcp Preferred 6d23h5m 2d23h5m fd00:10::101

图形界面(备用)

Windows DHCPv6 默认不广播前缀,需通过 RRAS 启用 RA

  1. 打开 路由和远程访问(RRAS)

  2. 配置为”本地路由模式(LAN Routing)”

  3. 网卡 → 右键 → 属性 → IPv6 标签页,勾选:

    • ✅ 启用 Router Advertisement
    • ✅ Managed Address Configuration(M 位)
    • ✅ Other Stateful Configuration(O 位)
    • ❌ 广播前缀(根据需求选择)
  4. 重启 RRAS 服务

✅ 三、配置 DNS 服务


📌 步骤 6:添加正向查找区域

  1. 打开 DNS 管理器
  2. 右键”正向查找区域” → 新建区域
  3. 区域名:如 internal.local
  4. 类型:主区域,存储在本地服务器
  5. 动态更新:选择”仅安全的”或”无”

📌 步骤 7:添加反向查找区域(IPv4)

  1. DNS 管理器 → 右键”反向查找区域” → 新建区域
  2. 网络 ID:如 10.168.192
  3. 完成命名:10.168.192.in-addr.arpa

✅ 四、安装 PXE 所需组件


📦 步骤 8:安装软件组件

  1. 安装 Windows 部署服务(WDS)

    • 打开”服务器管理器” → 添加角色

    • 勾选:

      • 部署服务器
      • 传输服务器
  2. 安装 Windows ADK + WinPE Add-ons

    • 下载地址:Windows ADK 下载

    • 选择组件:

      • Deployment Tools
      • Windows Preinstallation Environment(需 WinPE Add-ons)
  3. 安装 Microsoft Deployment Toolkit (MDT)

    • 下载地址:MDT 下载
    • 安装完成后打开:Deployment Workbench

✅ 五、配置 MDT 部署服务


⚙️ 步骤 9:创建部署共享目录

  1. 例如:C:\DeploymentShare
  2. Deployment Workbench → Deployment Shares → New Deployment Share
  3. 设置路径、共享名、描述

⚙️ 步骤 10:导入操作系统镜像

  1. 将 ISO 挂载或解压,导入其中的 install.wim
  2. Deployment Share → Operating Systems → Import Operating System

⚙️ 步骤 11:创建 Task Sequence

  1. Deployment Share → Task Sequences → New Task Sequence

  2. 配置:

    • Task ID:如 WS2025
    • 模板:Standard Client Task Sequence
    • 操作系统:选择上一步导入的镜像

⚙️ 步骤 12:配置无人值守部署(CustomSettings.ini/Bootstrap.ini/Task Squences/Unattend.xml)

CustomSettings.ini 示例:

路径:C:\DeploymentShare\Control\CustomSettings.ini

按照Model, Default的优先级顺序,如果client的Model型号匹配,则使用对应的设置,例如”Standard PC (Q35 + ICH9, 2009)”.

更多参数可以参考MDT 文档.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[Settings]
Priority=Model, Default
Properties=MyCustomProperty

[Default]
OSInstall=Y
SkipDeploymentComplete=YES
SkipBDDWelcome=YES
SkipTaskSequence=YES
TaskSequenceID=WS2025
SkipCapture=YES
SkipComputerName=YES
SkipUserData=YES
SkipSummary=YES
SkipFinalSummary=YES
SkipAdminPassword=YES
AdminPassword=Passw0rd
SkipProductKey=YES
SkipComputerBackup=YES
SkipBitLocker=YES
SkipDeploymentType=YES
DeploymentType=NEWCOMPUTER
KeyboardLocale=0409:00000409
UserLocale=en-US
UILanguage=en-US
TimeZone=Eastern Standard Time
SkipLocaleSelection=YES
JoinWorkgroup=WORKGROUP
SkipDomainMembership=YES
SkipTimeZone=YES
SkipApplications=YES
Applications001={2ef0539b-5ba0-4dbc-b8d8-daa573151b3d}
Applications002={b174dc6e-c0da-409a-b367-ca42fa541a18}

[Standard PC (Q35 + ICH9, 2009)]
TaskSequenceID=WS2019
OSDComputerName=Q35-#Right(Replace("%MACAddress001%",":",""),4)#

Bootstrap.ini 示例:

路径:C:\DeploymentShare\Control\Bootstrap.ini

1
2
3
4
5
6
7
8
9
[Settings]
Priority=Default

[Default]
DeployRoot=\\<wds 主机名>\DeploymentShare$
UserID=administrator
UserDomain=domain.com
UserPassword=Password
SkipBDDWelcome=YES

Task Squences 示例:

路径: C:\DeploymentShare\Control\<task squence id>\ts.xml

启用OS的EMS,添加以下内容到group name="Install"中的name="Install Operating System" 之后.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<step type="SMS_TaskSequence_RunCommandLineAction" name="Enable EMS" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS">
<defaultVarList>
<variable name="PackageID" property="PackageID"></variable>
<variable name="RunAsUser" property="RunAsUser">false</variable>
<variable name="SMSTSRunCommandLineUserName" property="SMSTSRunCommandLineUserName"></variable>
<variable name="SMSTSRunCommandLineUserPassword" property="SMSTSRunCommandLineUserPassword"></variable>
<variable name="LoadProfile" property="LoadProfile">false</variable>
</defaultVarList>
<action>bcdedit /set {default} ems yes</action>
</step>
<step type="SMS_TaskSequence_RunCommandLineAction" name="Set EMS settings" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS">
<defaultVarList>
<variable name="PackageID" property="PackageID"></variable>
<variable name="RunAsUser" property="RunAsUser">false</variable>
<variable name="SMSTSRunCommandLineUserName" property="SMSTSRunCommandLineUserName"></variable>
<variable name="SMSTSRunCommandLineUserPassword" property="SMSTSRunCommandLineUserPassword"></variable>
<variable name="LoadProfile" property="LoadProfile">false</variable>
</defaultVarList>
<action>bcdedit /emssettings EMSPORT:1 EMSBAUDRATE:115200</action>
</step>

关闭OS防火墙,放到group name="State Restore"中的step type="BDD_Gather之后

1
2
3
4
5
6
7
8
9
10
<step type="SMS_TaskSequence_RunCommandLineAction" name="Disable firewall" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS">
<defaultVarList>
<variable name="PackageID" property="PackageID"></variable>
<variable name="RunAsUser" property="RunAsUser">false</variable>
<variable name="SMSTSRunCommandLineUserName" property="SMSTSRunCommandLineUserName"></variable>
<variable name="SMSTSRunCommandLineUserPassword" property="SMSTSRunCommandLineUserPassword"></variable>
<variable name="LoadProfile" property="LoadProfile">false</variable>
</defaultVarList>
<action>netsh advfirewall set allprofiles state off</action>
</step>

启用RDP远程桌面,放到group name="State Restore"中的step type="BDD_Gather之后

1
2
3
4
5
6
7
8
9
10
<step type="SMS_TaskSequence_RunCommandLineAction" name="Enable RDP" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS">
<defaultVarList>
<variable name="PackageID" property="PackageID"></variable>
<variable name="RunAsUser" property="RunAsUser">false</variable>
<variable name="SMSTSRunCommandLineUserName" property="SMSTSRunCommandLineUserName"></variable>
<variable name="SMSTSRunCommandLineUserPassword" property="SMSTSRunCommandLineUserPassword"></variable>
<variable name="LoadProfile" property="LoadProfile">false</variable>
</defaultVarList>
<action>reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f</action>
</step>

Unattend.xml 示例

路径: C:\DeploymentShare\Control\<task squence id>\unattend.xml

设置ProductKey, key可以参考https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys

1
2
3
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<ProductKey>xxxxx-xxxxx-xxxxx-xxxxx-xxxxx</ProductKey>
</component>

⚙️ 步骤 13:集成UltraVNC到WinPE

  1. 下载UltraVNC UltraVNC x.x.x.x.zip
  2. 解压缩文件,并且将x64改名为VNC, 放到C:\DeploymentShare\ExtraFiles下面
  3. 编辑或创建VNC\UltraVNC.ini, 添加以下内容,为111111 base64编码后的值
    1
    2
    [UltraVNC]
    passwd=9065AD0D054101281E
  4. Deployment Share → 右键 → Properties → Windows PE → Platform → x64 → Exatra directory to add: → C:\DeploymentShare\ExtraFiles 然后保存
  5. 编辑C:\DeploymentShare\Control\<task squence id>\ts.xml, 添加以下内容到group name="Initialization", 关闭WinPE 防火墙并且运行UltraVNC
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <step type="SMS_TaskSequence_RunCommandLineAction" name="Disable firewall" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS">
    <defaultVarList>
    <variable name="PackageID" property="PackageID"></variable>
    <variable name="RunAsUser" property="RunAsUser">false</variable>
    <variable name="SMSTSRunCommandLineUserName" property="SMSTSRunCommandLineUserName"></variable>
    <variable name="SMSTSRunCommandLineUserPassword" property="SMSTSRunCommandLineUserPassword"></variable>
    <variable name="LoadProfile" property="LoadProfile">false</variable>
    </defaultVarList>
    <action>Wpeutil DisableFirewall</action>
    </step>
    <step type="SMS_TaskSequence_RunCommandLineAction" name="Start VNC" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS">
    <defaultVarList>
    <variable name="PackageID" property="PackageID"></variable>
    <variable name="RunAsUser" property="RunAsUser">false</variable>
    <variable name="SMSTSRunCommandLineUserName" property="SMSTSRunCommandLineUserName"></variable>
    <variable name="SMSTSRunCommandLineUserPassword" property="SMSTSRunCommandLineUserPassword"></variable>
    <variable name="LoadProfile" property="LoadProfile">false</variable>
    </defaultVarList>
    <action>cmd.exe /c start "" X:\VNC\winvnc.exe -run</action>
    </step>
  6. 在启动WinPE之后,可以使用UltraVNC连接PXE分配的IP打开VNC窗口,密码为设置的111111


⚙️ 步骤 14:生成 LiteTouchPE 引导镜像

  1. Deployment Share → 右键 → Update Deployment Share
  2. 自动生成 LiteTouchPE_x64.wim,路径如下:
    C:\DeploymentShare\Boot\LiteTouchPE_x64.wim

✅ 六、配置 WDS(PXE 启动服务)


🧩 步骤 15:配置 WDS 基础设置

  1. 打开”Windows 部署服务”管理器
  2. 设置 RemoteInstall 路径(如:C:\RemoteInstall
  3. 设置响应所有客户端(包括未知客户端)

🧩 步骤 16:添加引导镜像

  1. WDS → Boot Images → Add Boot Image
  2. 选择前面生成的 LiteTouchPE_x64.wim

🧩 步骤 17:可选安装镜像导入

  1. 从 ISO 中提取 install.wim
  2. WDS → Install Images → Add Image Group → 导入 install.wim

✅ 七、串口控制台(EMS)可选配置


🧵 步骤 18:启用 EMS(串口控制)

  1. 查询BCD中bootload 的identifier

    1
    bcdedit /store "C:\RemoteInstall\Boot\x64\Images\LiteTouchPE_x64.wim.bcd" /enum
  2. 设置指定identifier的EMS ON

    1
    bcdedit /store "C:\RemoteInstall\Boot\x64\Images\LiteTouchPE_x64.wim.bcd" /ems {<identifier>} ON
  3. 再次检查BCD是否包含 ems Yes

    1
    bcdedit /store "C:\RemoteInstall\Boot\x64\Images\LiteTouchPE_x64.wim.bcd" /enum

⚠️ 注意:务必使用 /store 指定 .bcd 文件路径,否则可能更改当前系统引导配置。


✅ 八、客户端部署测试与验证


🧪 步骤 19:客户端启动配置

  1. BIOS/UEFI 中设置 PXE 启动优先
  2. 启动后应进入 MDT LiteTouch PE 环境
  3. 自动执行无人值守部署任务序列

🧪 步骤 20:验证 DHCP 和 DNS 正常工作

客户端设置为自动获取 IP
执行命令:

1
2
3
4
ipconfig /release
ipconfig /renew
ipconfig /all
nslookup internal.local

✅ 九、静态地址分配(保留地址)


📌 DHCPv4 保留地址

  1. DHCP 管理器 → IPv4 → Reservations
  2. 新建 → 输入 MAC 地址与 IP 进行保留

📌 DHCPv6 保留地址

  1. 客户端执行 ipconfig /all 获取 DUID
  2. DHCP 管理器 → IPv6 → Reservations → 新建保留地址并输入 DUID

✅ 十、故障排查与日志定位


🔧 常见日志路径

阶段 日志路径
WinPE 阶段 X:\MININT\SMSOSD\OSDLOGS\
安装中 C:\MININT\SMSOSD\OSDLOGS\
安装后 C:\Windows\Temp\DeploymentLogs\

🧹 清除失败部署缓存(避免”in-progress”错误)

1
2
3
rd /s /q C:\MININT
rd /s /q C:\_SMSTaskSequence
del /f /q C:\*.xml