在 PowerShell Gallery 中有许多有用的 PowerShell 模块。有一个能帮助您管理更新。要下载和安装它,请运行:
1
| PS> Install-Module -Name PSWindowsUpdate -Scope CurrentUser -Force
|
它添加了一系列与 Windows Update 相关的新命令:
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
| PS> Get-Command -Module PSWindowsUpdate
CommandType Name Version Source ----------- ---- ------- ------ Alias Clear-WUJob 2.1.1.2 PSWindowsUpdate Alias Download-WindowsUpdate 2.1.1.2 PSWindowsUpdate Alias Get-WUInstall 2.1.1.2 PSWindowsUpdate Alias Get-WUList 2.1.1.2 PSWindowsUpdate Alias Hide-WindowsUpdate 2.1.1.2 PSWindowsUpdate Alias Install-WindowsUpdate 2.1.1.2 PSWindowsUpdate Alias Show-WindowsUpdate 2.1.1.2 PSWindowsUpdate Alias UnHide-WindowsUpdate 2.1.1.2 PSWindowsUpdate Alias Uninstall-WindowsUpdate 2.1.1.2 PSWindowsUpdate Cmdlet Add-WUServiceManager 2.1.1.2 PSWindowsUpdate Cmdlet Enable-WURemoting 2.1.1.2 PSWindowsUpdate Cmdlet Get-WindowsUpdate 2.1.1.2 PSWindowsUpdate Cmdlet Get-WUApiVersion 2.1.1.2 PSWindowsUpdate Cmdlet Get-WUHistory 2.1.1.2 PSWindowsUpdate Cmdlet Get-WUInstallerStatus 2.1.1.2 PSWindowsUpdate Cmdlet Get-WUJob 2.1.1.2 PSWindowsUpdate Cmdlet Get-WULastResults 2.1.1.2 PSWindowsUpdate Cmdlet Get-WURebootStatus 2.1.1.2 PSWindowsUpdate Cmdlet Get-WUServiceManager 2.1.1.2 PSWindowsUpdate Cmdlet Get-WUSettings 2.1.1.2 PSWindowsUpdate Cmdlet Invoke-WUJob 2.1.1.2 PSWindowsUpdate Cmdlet Remove-WindowsUpdate 2.1.1.2 PSWindowsUpdate Cmdlet Remove-WUServiceManager 2.1.1.2 PSWindowsUpdate Cmdlet Set-PSWUSettings 2.1.1.2 PSWindowsUpdate Cmdlet Set-WUSettings 2.1.1.2 PSWindowsUpdate Cmdlet Update-WUModule 2.1.1.2 PSWindowsUpdate
|
大多数命令需要提升权限的 shell 才能正常工作,但每个人都可以获得基本信息。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| PS> Get-WULastResults WARNING: To perform some operations you must run an elevated Windows PowerShell console.
ComputerName LastSearchSuccessDate LastInstallationSuccessDate ------------ --------------------- --------------------------- DESKTOP-8DVNI43 22.01.2020 11:29:24 22.01.2020 11:29:52
PS> Get-WUApiVersion WARNING: To perform some operations you must run an elevated Windows PowerShell console.
ComputerName PSWindowsUpdate PSWUModuleDll ApiVersion WuapiDllVersion ------------ --------------- ------------- ---------- --------------- DESKTOP-8... 2.1.1.2 2.0.6995.28496 8.0 10.0.18362.387
|