当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PSWindowsUpdate - 管理 Windows 更新

作者:精品下载站 日期:2024-12-14 17:27:37 浏览:16 分类:玩电脑

PSWindowsUpdate - 管理 Windows 更新


`PSWindowsUpdate` 模块是一个 PowerShell 模块,提供用于管理 Windows 更新的 cmdlet。它在 Windows 中默认不可用,但可以从 PowerShell Gallery 免费获取。

PSWindowsUpdates 模块可用于执行以下操作:

  1. 检查可用的更新
  2. 安装 Windows 更新
  3. 删除 Windows 更新
  4. 隐藏更新
  5. 查看更新历史
  6. 列出可用更新

在本文中,我们将讨论如何使用 PSWindowsUpdate 模块来管理 Windows 更新。

如何在 Windows 中安装 PSWindowsUpdate 模块

要在 Windows 中安装 PSWindowsUpdate 模块,请在 PowerShell 中运行以下命令。

Install-Module PSWindowsUpdate

在上面的 PowerShell 脚本中,Install-Module 命令安装 PSWindowsUpdate 模块。

下面给出了安装 PSWindowsUpdate 模块的上述 PowerShell 脚本的输出。

[玩转系统] PSWindowsUpdate - 管理 Windows 更新

安装模块后,您可以使用以下命令获取有关 PSWindowsUpdate 的信息。

Get-Commmand -module PSWindowsUpdate

此 PowerShell 命令返回 PSWindowsUpdate 模块中可用的 cmdlet 列表。

上述命令的输出显示所有 cmdlet 的列表。

让我们了解一下模块命令的简要说明。

  1. Clear-WUJob:从任务计划程序中清除 Windows 更新作业。
  2. 下载 WindowsUpdate: 下载可用的 Windows 更新。
  3. Get-WUInstall:获取有关待安装的 Windows 更新的信息。
  4. Get-WUList: 显示可用 Windows 更新的列表。
  5. 隐藏 WindowsUpdate:隐藏特定的 Windows 更新。
  6. 安装WindowsUpdate:安装挂起的Windows更新。
  7. Show-WindowsUpdate:显示隐藏的 Windows 更新。
  8. 取消隐藏-WindowsUpdate:取消隐藏以前隐藏的 Windows 更新。
  9. Uninstall-WindowsUpdate:卸载特定的 Windows 更新。
  10. Add-WUServiceManager: 注册 Windows Update 服务管理器。
  11. Enable-WURemoting:为远程 PSWindowsUpdate 使用启用 Windows Defender 防火墙规则。
  12. Get-WindowsUpdate:获取可用 Windows 更新的列表并管理其安装。
  13. Get-WUApiVersion:检索 Windows 更新代理版本。
  14. Get-WUHistory:显示已安装更新的历史记录。
  15. Get-WUInstallerStatus:检查 Windows Installer 服务状态。
  16. Get-WUJob:检查任务计划程序中的 Windows 更新作业任务。
  17. Get-WULastResults:获取上次搜索和安装结果。
  18. Get-WUOfflineMSU:检索脱机MSU文件信息。
  19. Get-WURebootStatus:检查更新是否需要重新启动系统。
  20. Get-WUServiceManager:列出可用的更新源。
  21. Get-WUSettings:检索 Windows 更新客户端设置。
  22. Invoke-WUJob:远程执行PSWindowsUpdate任务。
  23. 删除-WindowsUpdate:删除特定的 Windows 更新。
  24. Remove-WUServiceManager:禁用 Windows 更新服务管理器。
  25. Reset-WUComponents:将 Windows Update 代理重置为其默认状态。
  26. Set-PSWUSettings: 将 PSWindowsUpdate 模块设置保存到 XML 文件。
  27. Set-WUSettings: 配置 Windows 更新客户端设置。
  28. Update-WUModule:更新 PSWindowsUpdate 模块。

如何在 PowerShell 中检查可用的 Windows 更新

要在 PowerShell 中检查可用的 Windows 更新,请使用 PSWindowsUpdate 模块中提供的 Get-WindowsUpdate cmdlet。

Get-WindowsUpdate

如何使用 PowerShell 安装所有可用的 Windows 更新

要在 PowerShell 中安装所有可用的 Windows 更新,请使用 PSWIndowsUpdate 模块中提供的 Install-WindowsUpdate 命令。

Install-WindowsUpdate -AcceptAll  

上述 PowerShell 命令 Install-WndowsUpdate 使用参数 -AcceptAll 在 Windows 中安装所有更新。

安装 Windows 更新后,使用 PSWindowsUpdate 模块中提供的 Get-WURebootStatus 命令检查是否需要重新启动。

如何在 PowerShell 中删除 Windows 更新

您可以使用 PSWindowsUpdate 模块中提供的 PowerShell 命令 Remove-WindowsUpdate 来删除 Windows 更新。

Remove-WindowsUpdate -KBArticleID KB4601395

在上述 PowerShell 脚本中,Remove-WindowsUpdate 命令删除具有 KBArticleId KB4601395 的 Windows 更新。

如何在 PowerShell 中隐藏 Windows 更新

用于隐藏 Windows 更新的 PowerShell 命令是 Hide-WindowsUpdate

Hide-WindowsUpdate -KBArticleID KB4601395

此 PowerShell 命令 Hide-WindowsUpdate 使用参数 -KBArticleId 作为 KB4601395 来隐藏更新。

如何在 PowerShell 中查看 Windows 更新历史记录

要在 PowerShell 中查看 Windows 更新历史记录,请使用命令 Get-WUHistory

Get-WUHistory

上述 PowerShell 命令 Get-WUHistory 返回 Windows 更新列表以及 ComputerName、OperationName、Result、Date 和 Title。

酷提示:如何在 PowerShell 中获取最近 30 天的更新!

如何使用 PowerShell 列出可用更新

用于列出可用 Windows 更新的 PowerShell 命令是 Get-WUList

Get-WUList

此 PowerShell 命令返回当前计算机可用的更新列表。

要检查远程计算机上可用的 Windows 更新列表,请运行以下命令。

Get-WUList -Computer INCOR-EU-20

酷提示:如何使用 PowerShell 检查已安装的 Windows 更新!

结论

希望以上关于如何在PowerShell中使用PSWindowsUpdate模块的文章对您有所帮助。

PSWindowsUpdate 模块提供用于管理 Windows 更新的 cmdlet。您可以了解有关用于管理软件包的 PackageManagement 模块的更多信息。

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯