FeaturedPower ShellSCCMScripts
get patch installed as background job
$servers = Get-Content -Path "C:\servers.txt" foreach($comp in $servers){ $pingtest = Test-Connection -ComputerName $comp -Quiet -Count 1 -ErrorAction SilentlyContinue if($pingtest){ Write-Host($comp + " is online") } else{ Write-Host($comp + " is not reachable") -ForegroundColor Red } } $s = New-PSSession -computername $servers Invoke-Command -session $s -scriptblock { start-job -ScriptBlock { $kb = 'KB5006714' $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" } } } ########################################################################################## Invoke-Command -Session $s -ScriptBlock {Get-Job } Invoke-Command -Session $s -ScriptBlock {receive-job -id 1 -Keep } > c:\hotfix.csv ##once done, uncomment out below command and use it to clean up all background jobs #get-job | Remove-Job