三二互联专业提供速度最快最稳定的美国服务器、香港服务器。中美直连,亚洲优化![ 代理登陆 ] [ 付款方式 ] [ 找回密码 ][ 电子协议责任书 ]
硬件资源保障

采用高配品牌服务器

主流强悍CPU配置

确保服务高速稳定运行

中美直连线路

中美直连亚洲优化

采用中国CN2骨干网络

保证速度飞快稳定高效

如何使用PowerShell配置Windows Update服务?

美国、香港服务器

如何使用PowerShell配置Windows Update服务?

10-01   来源:

 使用 PowerShell 配置 Windows Update 服务功能强大且灵活,支持更精细的控制(如设置更新策略、管理更新服务状态等)。以下是常用配置方法:

前提:以管理员身份运行 PowerShell
按下 Win + S,搜索 “PowerShell”;
右键 “Windows PowerShell”,选择 “以管理员身份运行”(必须管理员权限,否则部分命令会失败)。
一、管理 Windows Update 服务状态
通过 Get-Service、Start-Service 等 cmdlet 控制服务的启动 / 停止。
1. 查看 Windows Update 服务状态
powershell
# 查看服务状态(运行中/已停止)、启动类型等
Get-Service -Name wuauserv | Select-Object Name, Status, StartType
2. 启动 / 停止服务
powershell
# 启动服务
Start-Service -Name wuauserv -PassThru
 
# 停止服务
Stop-Service -Name wuauserv -Force -PassThru  # -Force 强制停止依赖该服务的进程
3. 修改服务启动类型
powershell
# 设置为自动启动(推荐)
Set-Service -Name wuauserv -StartupType Automatic
 
# 设置为自动(延迟启动)
Set-Service -Name wuauserv -StartupType AutomaticDelayedStart
 
# 设置为手动启动
Set-Service -Name wuauserv -StartupType Manual
 
# 禁用服务(停止自动更新)
Set-Service -Name wuauserv -StartupType Disabled
二、配置自动更新策略(通过注册表)
PowerShell 可直接修改注册表,设置自动更新的具体行为(如下载、安装策略)。
1. 启用自动更新并设置为 “自动下载并安装”(推荐)
powershell
# 创建注册表路径(若不存在)
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
 
# 启用自动更新(0=启用,1=禁用)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Value 0 -Type DWord -Force
 
# 设置更新选项(2=自动下载并安装,3=通知下载和安装,4=自动下载并计划安装)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUOptions" -Value 2 -Type DWord -Force
2. 配置更新安装时间(适用于 “自动下载并计划安装” 策略)
powershell
# 设置每天安装时间(小时,0-23,例如 3 表示凌晨3点)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "ScheduledInstallTime" -Value 3 -Type DWord -Force
3. 延迟更新(暂停质量更新 / 功能更新)
powershell
# 延迟质量更新(0-30天,例如延迟7天)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferQualityUpdates" -Value 1 -Type DWord -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferQualityUpdatesPeriodInDays" -Value 7 -Type DWord -Force
 
# 延迟功能更新(0-365天,例如延迟30天)
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferFeatureUpdates" -Value 1 -Type DWord -Force
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferFeatureUpdatesPeriodInDays" -Value 30 -Type DWord -Force
三、重置 Windows Update 组件(修复服务异常)
当服务卡顿、更新失败时,可通过 PowerShell 重置相关组件:
powershell
# 停止相关服务
Stop-Service -Name wuauserv, cryptSvc, bits, msiserver -Force
 
# 重命名缓存文件夹(备份并清除旧缓存)
Rename-Item -Path "C:\Windows\SoftwareDistribution" -NewName "SoftwareDistribution.old" -Force -ErrorAction SilentlyContinue
Rename-Item -Path "C:\Windows\System32\catroot2" -NewName "catroot2.old" -Force -ErrorAction SilentlyContinue
 
# 重启服务
Start-Service -Name wuauserv, cryptSvc, bits, msiserver
 
# 重新注册相关 DLL 文件
$dlls = @(
    "wuapi.dll", "wuaueng.dll", "wuaueng1.dll", "wucltui.dll",
    "wups.dll", "wups2.dll", "wuweb.dll", "qmgr.dll", "qmgrprxy.dll"
)
foreach ($dll in $dlls) {
    regsvr32.exe /s $dll
}
 
Write-Host "Windows Update 组件已重置完成,请重启电脑后重试更新。"
四、使用 PSWindowsUpdate 模块(扩展功能)
安装微软官方的 PSWindowsUpdate 模块,可直接查询、下载、安装更新(需联网)。
1. 安装模块
powershell
# 安装模块(需允许执行脚本:Set-ExecutionPolicy RemoteSigned)
Install-Module -Name PSWindowsUpdate -Force -AllowClobber
2. 常用命令示例
powershell
# 检查可用更新
Get-WindowsUpdate
 
# 安装所有可用更新
Install-WindowsUpdate -AcceptAll -AutoReboot  # -AutoReboot 表示安装后自动重启
 
# 隐藏特定更新(例如 KB5030310)
Hide-WindowsUpdate -KBArticleID "KB5030310" -Confirm:$false
 
# 显示已隐藏的更新
Get-WindowsUpdate -Hidden
验证配置结果
查看服务状态:Get-Service wuauserv 确认启动类型和运行状态;
检查更新设置:打开 “设置 → 更新和安全 → Windows 更新”,验证策略是否生效;
测试更新功能:执行 Get-WindowsUpdate(需安装模块)或点击 “检查更新”,确认可正常扫描更新。
通过 PowerShell 配置 Windows Update 服务,适合自动化脚本、批量管理或需要精确控制的场景。其中,PSWindowsUpdate 模块提供了更直观的更新管理功能,推荐进阶用户使用。

三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快

上一篇:没有了 下一篇:如何通过命令提示符配置Windows Update服务?

美国GIA服务器三二互联版权所有 WWW.250.cc 2008-2015 All Rights Reserved
三二互联 - 专业的美国C3服务器香港vps、抗DOOS流量清洗、云备份系统、网站加速系统、美国GIA服务器和香港云服务器产品提供商
三二互联24小时在线工单系统为您提供全面、专业、周到的技术支持与服务
咨询热线:400-679-9994(免长话费)