I’ve written a script which gets data from servers via individual jobs and then receives the data as soon as one is completed. My question is, can this data be kept under one header? As it is producing a header each time.
$Jobs = get-job -name "StartPatch-*" $Results = @() $Count = 0 do{ Write-Progress -Activity "Running job to Start-OSPatching For servers" -PercentComplete ($Count / $Jobs.Count * 100) -Status "Completed $count of $($Jobs.count)" $Result = get-job -name "StartPatch-*" | where state -EQ Completed | select -ExcludeProperty RunspaceId |receive-job $Results += $Result $Result | select-object -property * -ExcludeProperty ` RunspaceId,` PSComputerName,` PSShowComputerName | sort Error -Descending | Format-Table $Count = (get-job -name "StartPatch-*" | where state -eq completed).count } while(Get-job -name "StartPatch-*" | where HasMoreData -eq True)
Results look like this:
Patching Please wait... Server Error Patches Require Restart LastPatch ------ ----- ----------------------- --------- core2 Failed: Failed to start Patch Connect on core2 0 0 Server Error Patches Require Restart LastPatch ------ ----- ----------------------- --------- core1 Failed: Failed to start Patch Connect on core1 0 0 Server Error Patches Require Restart LastPatch ------ ----- ----------------------- --------- condc02v Failed: Failed to start Patch Connect on condc02v 0 0
Plan is for this:
Patching Please wait... Server Error Patches Require Restart LastPatch ------ ----- ----------------------- --------- core2 Failed: Failed to start Patch Connect on core2 0 0 core1 Failed: Failed to start Patch Connect on core1 0 0 condc02v Failed: Failed to start Patch Connect on condc02v 0 0
submitted by /u/Mskews
[link] [comments]
The post Individual jobs with one header for results? appeared first on How to Code .NET.