Windows PXE 自动化部署环境搭建
🌐 Windows PXE 自动化部署环境搭建
✅ 一、环境准备与网络配置
🧾 步骤 1:配置服务器静态 IP(IPv4 和 IPv6)
控制面板 → 网络和共享中心 → 更改适配器设置
右键网络 → 属性 → 选择
IPv4和IPv6→ 属性示例配置:
IPv4:
- IP 地址:
192.168.10.1 - 子网掩码:
255.255.255.0 - 默认网关:
192.168.10.1
- IP 地址:
IPv6:
- 地址:
fd00:10::1 - 前缀长度:
64 - 网关:
fd00:10::1
- 地址:
点击”确定”保存
🧾 步骤 2:安装 DHCP 和 DNS 服务
打开 服务器管理器
点击”添加角色和功能”
选择:
- ✅ DHCP Server(DHCP 服务器)
- ✅ DNS Server(DNS 服务器)
一路”下一步”直到安装完成
安装完成后根据提示启动 DHCP 配置向导并完成设置
✅ 二、配置 DHCPv4 和 DHCPv6 服务
📌 步骤 3:配置 DHCPv4 服务
打开 DHCP 管理器
右键
IPv4→ 新建作用域设置作用域信息:
- 名称:
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:配置 DHCPv6 服务
DHCP 管理器中 →
IPv6→ 新建作用域配置如下:
- 名称:
Internal-IPv6 - 前缀:
fd00:10:: - 前缀长度:64
- 范围编号:1 - 9999
- 名称:
完成并激活作用域
📌 步骤 5:启用 IPv6 Router Advertisement(RA)
命令行方式:
查询interface id
1
2
3
4
5netsh interface ipv6 show interface
Idx Met MTU State Name
--- ---------- ---------- ------------ ---------------------------
<interface id> 15 1500 connected Ethernet启用 IPv6 转发和 RA 广播
1
2
3
4
5netsh 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检查状态
1
2
3
4
5
6
7
8
9netsh 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
打开
路由和远程访问(RRAS)配置为”本地路由模式(LAN Routing)”
网卡 → 右键 → 属性 → IPv6 标签页,勾选:
- ✅ 启用 Router Advertisement
- ✅ Managed Address Configuration(M 位)
- ✅ Other Stateful Configuration(O 位)
- ❌ 广播前缀(根据需求选择)
重启 RRAS 服务
✅ 三、配置 DNS 服务
📌 步骤 6:添加正向查找区域
- 打开
DNS 管理器 - 右键”正向查找区域” → 新建区域
- 区域名:如
internal.local - 类型:主区域,存储在本地服务器
- 动态更新:选择”仅安全的”或”无”
📌 步骤 7:添加反向查找区域(IPv4)
- DNS 管理器 → 右键”反向查找区域” → 新建区域
- 网络 ID:如
10.168.192 - 完成命名:
10.168.192.in-addr.arpa
✅ 四、安装 PXE 所需组件
📦 步骤 8:安装软件组件
安装 Windows 部署服务(WDS)
打开”服务器管理器” → 添加角色
勾选:
- 部署服务器
- 传输服务器
安装 Windows ADK + WinPE Add-ons
下载地址:Windows ADK 下载
选择组件:
- Deployment Tools
- Windows Preinstallation Environment(需 WinPE Add-ons)
安装 Microsoft Deployment Toolkit (MDT)
- 下载地址:MDT 下载
- 安装完成后打开:Deployment Workbench
✅ 五、配置 MDT 部署服务
⚙️ 步骤 9:创建部署共享目录
- 例如:
C:\DeploymentShare - Deployment Workbench → Deployment Shares → New Deployment Share
- 设置路径、共享名、描述
⚙️ 步骤 10:导入操作系统镜像
- 将 ISO 挂载或解压,导入其中的
install.wim - Deployment Share → Operating Systems → Import Operating System
⚙️ 步骤 11:创建 Task Sequence
Deployment Share → Task Sequences → New Task Sequence
配置:
- Task ID:如
WS2025 - 模板:Standard Client Task Sequence
- 操作系统:选择上一步导入的镜像
- Task ID:如
⚙️ 步骤 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 | [Settings] |
Bootstrap.ini 示例:
路径:C:\DeploymentShare\Control\Bootstrap.ini
1 | [Settings] |
Task Squences 示例:
路径: C:\DeploymentShare\Control\<task squence id>\ts.xml
启用OS的EMS,添加以下内容到group name="Install"中的name="Install Operating System" 之后.
1 | <step type="SMS_TaskSequence_RunCommandLineAction" name="Enable EMS" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS"> |
关闭OS防火墙,放到group name="State Restore"中的step type="BDD_Gather之后
1 | <step type="SMS_TaskSequence_RunCommandLineAction" name="Disable firewall" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS"> |
启用RDP远程桌面,放到group name="State Restore"中的step type="BDD_Gather之后
1 | <step type="SMS_TaskSequence_RunCommandLineAction" name="Enable RDP" description="" disable="false" continueOnError="false" startIn="" successCodeList="0 3010" runIn="WinPEandFullOS"> |
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 | <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"> |
⚙️ 步骤 13:集成UltraVNC到WinPE
- 下载UltraVNC
UltraVNC x.x.x.x.zip - 解压缩文件,并且将x64改名为VNC, 放到
C:\DeploymentShare\ExtraFiles下面 - 编辑或创建
VNC\UltraVNC.ini, 添加以下内容,为111111base64编码后的值1
2[UltraVNC]
passwd=9065AD0D054101281E - Deployment Share → 右键 → Properties → Windows PE → Platform → x64 → Exatra directory to add: →
C:\DeploymentShare\ExtraFiles然后保存 - 编辑
C:\DeploymentShare\Control\<task squence id>\ts.xml, 添加以下内容到group name="Initialization", 关闭WinPE 防火墙并且运行UltraVNC1
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> - 在启动WinPE之后,可以使用UltraVNC连接PXE分配的IP打开VNC窗口,密码为设置的
111111
⚙️ 步骤 14:生成 LiteTouchPE 引导镜像
- Deployment Share → 右键 → Update Deployment Share
- 自动生成
LiteTouchPE_x64.wim,路径如下:C:\DeploymentShare\Boot\LiteTouchPE_x64.wim
✅ 六、配置 WDS(PXE 启动服务)
🧩 步骤 15:配置 WDS 基础设置
- 打开”Windows 部署服务”管理器
- 设置 RemoteInstall 路径(如:
C:\RemoteInstall) - 设置响应所有客户端(包括未知客户端)
🧩 步骤 16:添加引导镜像
- WDS → Boot Images → Add Boot Image
- 选择前面生成的
LiteTouchPE_x64.wim
🧩 步骤 17:可选安装镜像导入
- 从 ISO 中提取
install.wim - WDS → Install Images → Add Image Group → 导入
install.wim
✅ 七、串口控制台(EMS)可选配置
🧵 步骤 18:启用 EMS(串口控制)
查询BCD中bootload 的identifier
1
bcdedit /store "C:\RemoteInstall\Boot\x64\Images\LiteTouchPE_x64.wim.bcd" /enum
设置指定identifier的EMS ON
1
bcdedit /store "C:\RemoteInstall\Boot\x64\Images\LiteTouchPE_x64.wim.bcd" /ems {<identifier>} ON
再次检查BCD是否包含
ems Yes1
bcdedit /store "C:\RemoteInstall\Boot\x64\Images\LiteTouchPE_x64.wim.bcd" /enum
⚠️ 注意:务必使用
/store指定.bcd文件路径,否则可能更改当前系统引导配置。
✅ 八、客户端部署测试与验证
🧪 步骤 19:客户端启动配置
- BIOS/UEFI 中设置 PXE 启动优先
- 启动后应进入 MDT LiteTouch PE 环境
- 自动执行无人值守部署任务序列
🧪 步骤 20:验证 DHCP 和 DNS 正常工作
客户端设置为自动获取 IP
执行命令:
1 | ipconfig /release |
✅ 九、静态地址分配(保留地址)
📌 DHCPv4 保留地址
- DHCP 管理器 → IPv4 → Reservations
- 新建 → 输入 MAC 地址与 IP 进行保留
📌 DHCPv6 保留地址
- 客户端执行
ipconfig /all获取 DUID - DHCP 管理器 → IPv6 → Reservations → 新建保留地址并输入 DUID
✅ 十、故障排查与日志定位
🔧 常见日志路径
| 阶段 | 日志路径 |
|---|---|
| WinPE 阶段 | X:\MININT\SMSOSD\OSDLOGS\ |
| 安装中 | C:\MININT\SMSOSD\OSDLOGS\ |
| 安装后 | C:\Windows\Temp\DeploymentLogs\ |
🧹 清除失败部署缓存(避免”in-progress”错误)
1 | rd /s /q C:\MININT |
