如何使用PowerShell比较两台Windows服务器之间的已安装修补程序?

我需要使用PowerShell比较开发者和生产环境之间已经安装的补丁。 我该怎么做?

我最近在这个问题上发表了博客,并提出了这个脚本。 您既可以作为两台计算机上的pipe理员用户运行,也可以使用get-hotfix命令上的-Credential选项。

 $server1 = Read-Host "Server 1" $server2 = Read-Host "Server 2" $server1Patches = get-hotfix -computer $server1 | Where-Object {$_.HotFixID -ne "File 1"} $server2Patches = get-hotfix -computer $server2 | Where-Object {$_.HotFixID -ne "File 1"} Compare-Object ($server1Patches) ($server2Patches) -Property HotFixID 
 clear-host $machine1=Read-Host "Enter Machine Name 1:-" $machine2=Read-Host "Enter Machine Name 2:-" $machinesone=@(Get-wmiobject -computername $machine1 -Credential Domain\Adminaccount -query 'select hotfixid from Win32_quickfixengineering') $machinestwo=@(Get-WmiObject -computername $machine2 -Credential Domain\Adminaccount -query 'select hotfixid from Win32_quickfixengineering') Compare-Object -RefernceObject $machinesone -DiffernceObject $machinestwo -Property hotfixid