PowerShell을 사용하여 두 Windows 서버간에 설치된 핫픽스를 어떻게 비교할 수 있습니까? PowerShell을 사용하여 개발 환경과 프로덕션 환경간에

PowerShell을 사용하여 개발 환경과 프로덕션 환경간에 설치된 패치를 비교해야합니다. 어떻게해야합니까?



답변

나는 최근 에이 문제에 대해 블로그를 작성 하고이 스크립트를 생각해 냈습니다. 두 시스템 모두에서 관리자 인 사용자로 실행하거나 명령 에서 -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


답변

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


답변