使用 Powershell 下载并安装 Windows 更新

Powershell 命令列表

以下是可用于控制 Windows 更新的 Powershell cmdlet

 

Download-WindowsUpdate(又名 Get-WindowsUpdate -Download):下载更新

Get-WUList:获取满足特定条件的可用更新列表。

Get-WUInstall、Install-WindowsUpdate:下载并安装更新。

Add-WUOfflineSync : 离线保存扫描仪服务

Get-WUServiceManager:显示服务管理器的配置。

Get-WUHistory:获取以前更新的列表。

Get-WUInstallerStatus:检查 Windows 更新安装程序的状态。

Get-WURebootStatus:检查 Windows 更新的重启状态并提供重启 PC。

Get-W UUninstall:卸载更新。

Hide-WindowsUpdate(别名 Get-WindowsUpdate -Hide: $ false):隐藏更新。

Remove-WUOfflineSync:注销离线扫描仪服务。

 

检查更新

这是列出等待安装的 Windows 更新更新的 Powershell 命令:

Get-WUlist

并列出来自远程 PC 的更新:

Get-WUList -ComputerName NomDeLaMachine

安装更新

这是安装所有更新的命令:

Install-WindowsUpdate -AcceptAll

并强制重启:

Install-WindowsUpdate -AcceptAll -AutoReboot

还要在 PowerShell 中安装特定更新:

Get-WindowsUpdate -KBArticleID KB2267602, KB4533002 -Install

最后要排除更新,这里是 PowerShell 命令:

Install-WindowsUpdate -NotCategory "Drivers" -NotTitle OneDrive -NotKBArticleID KB4011670 -AcceptAll -IgnoreReboot

在远程 PC 上安装更新

如果您想通过 PowerShell 在远程 PC 上安装 Windows 更新更新:

$Serveurs= "serveur1, serveur2, serveur3"
Invoke-WUJob -ComputerName $ServerNames -Script {ipmo PSWindowsUpdate; Install-WindowsUpdate -AcceptAll | Out-File C:WindowsPSWindowsUpdate.log } -RunNow -Confirm:$false

阻止和隐藏更新

$HideList = "KB4489873", "KB4489243"
Get-WindowsUpdate -KBArticleID $HideList –Hide

最后列出隐藏的更新:

Get-WindowsUpdate –IsHidden

最后要解锁更新,这里有两个不同的 Powershell 命令:

Get-WindowsUpdate -KBArticleID $HideList -WithHidden -Hide:$false
Show-WindowsUpdate -KBArticleID $HideList

卸载更新

要使用 PowerShell 卸载更新,我们使用 Get-WUUninstall:

Get-WUUninstall -KBArticleID KBXXX
上一篇:emacs和python更新模块


下一篇:Emacs Python.el,语法突出显示的怪癖