Get-hotfix -asJob Remote machine

Get-hotfix -asJob Remote machine

use this script to get hotfix details from remote machine as -asJob

 

#$servers = ('chn6vmdp01', 'ca7vmdp01', 'gbr2vmdp01')
$servers = Get-Content -Path "C:\dps.txt"


invoke-command -computername $servers -ScriptBlock {

            $kb = 'KB5006669'
            $patch = Get-hotfix | Where { $_.HotFixID -eq $kb }
            if($patch ){
                        Write-output "$env:computername  - $kb - installed - $($patch.installedon)" 
                        #$patch.  | Sort-Object -Property HotFixID -ForegroundColor Green
                        }else {
                            Write-output "$env:computername  - $kb - Notinstalled" 
                        }
                        
                 
 } -Asjob -JobName hotfix 


  $job
  $job = get-job -Name hotfix
   
   $job | receive-job -Keep > c:\patch.txt 


   
 get-job | remove-job

 

Exit mobile version