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


9

我需要比较使用PowerShell在开发环境和生产环境之间安装的补丁。我怎样才能做到这一点?

Answers:


11

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

$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

1
从不知道get-hotfix。那里的信息很大。
Mike

使用Get-Hotfix时要小心,它只会报告一部分补丁。有关更多信息,请参见此Hey Scripting Guy文章。@Mike
Ashley

0
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

1
您能否解释一下查询WMI可能比在每个主机上运行本机PowerShell更好?
blaughw 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.