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
