powershell - 使用 PowerShell 将 PC 名称和所需的更新从 WSUS 导出到 CSV
问题描述
我正在尝试使用 PowerShell 从 WSUS 导出 CSV 文件,其中包含需要更新的所有计算机的列表以及每台特定计算机所需的更新的标题或 KB。像这样的东西...
计算机 1、更新 1、更新 2
计算机 2、更新 1、更新 3、更新 5
计算机 3、更新 2、更新 4
我在 TechNet 上找到了这个脚本,它返回计算机名称和需要多少更新,但它不返回更新的标题,它可能会返回 WSUS 中的所有计算机,而不仅仅是需要更新的计算机(我是在目前只有一台计算机的测试环境中)。
Function Get-WSUSClientNeeded {
[cmdletbinding()]
Param (
[parameter(Mandatory=$true)]
[string]$WsusServer
)
#Load assemblies
[void][system.reflection.assembly]::LoadWithPartialName('Microsoft.UpdateServices.Administration')
#Connect to WSUS
$Global:wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($WsusServer,$False,8530)
#Create Scope objects
$computerscope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
$updatescope = New-Object Microsoft.UpdateServices.Administration.UpdateScope
#Get Update Summary
$wsus.GetSummariesPerComputerTarget($updatescope,$computerscope) | ForEach {
New-Object PSObject -Property @{
ComputerName = ($wsus.GetComputerTarget([guid]$_.ComputerTargetId)).FullDomainName
NeededCount = ($_.DownloadedCount + $_.NotInstalledCount)
DownloadedCount = $_.DownloadedCount
NotApplicableCount = $_.NotApplicableCount
NotInstalledCount = $_.NotInstalledCount
InstalledCount = $_.InstalledCount
FailedCount = $_.FailedCount
}
}
}
Get-WSUSClientNeeded -WsusServer 'Server' | Select ComputerName, NeededCount
我对 PowerShell 非常陌生,因此将不胜感激任何帮助。
谢谢!
解决方案
事实证明这比预期的要容易得多。
Get-WindowsUpdate -WindowsUpdate
Get-WindowsUpdate将从在线来源返回可用更新。-WindowsUpdate参数将从 WSUS 返回更新。确保首先导入 PSWindowsUpdate 模块。
推荐阅读
- neural-network - 如何使用枕头库创建的图像作为神经网络的输入
- d3.js - 如何设置
d3 中的元素,填充其父级的所有剩余空间? - reactjs - i18 中的 useTranslation 钩子需要一些时间来渲染原始文本
- java - 使用 Java SDK sellpartner-api-aa-java 在 Java 连接 SP-API 中遇到问题
- powerbi - Power BI - 发布到 Web 和网站之间的区别(门户)
- swift - Crashlytics 不适用于 Swift 包管理器 iOS 14.6
- python - 如何提取 Levensthein 距离给出的差异?
- c++ - 澄清两个指针方法的工作
- azure - 当我通过 Linux Web 应用程序中的 devops 部署角度代码时,没有显示任何 UI
- webrtc - 实验性 libp2p-webrtc-star 信号服务器是否仅在本地工作?