Reputation: 1117
Using powershell and i have several items that i'm triggering using start-job. now i would like to display some statuses of the job, but the problem is that the autogenerated name Job1-x is not very helpful if you have many jobs going.
How can i add a custom name to a job so that i can indicate the status when the jobs have finished.
Start-Job -ScriptBlock { tfsbuild start /collection:"xxx" /builddefinition:"xxx1" }
Start-Job -ScriptBlock { tfsbuild start /collection:"xxx" /builddefinition:"xxx2" }
Do
{
$meJobStatesRunning = Get-Job -State Running
Start-Sleep -s 1 #give time for job to process before checking.
} While ($meJobStatesRunning -notlike '')
Get-Job | foreach { if ($_.state -eq "Completed") {write-host -f green $_.name $_.state } else {write-host -f red $_.name $_.state } }
Upvotes: 1
Views: 1379
Reputation: 47812
Yes, use the -Name
parameter.
Start-Job -Name MyName -ScriptBlock { tfsbuild start /collection:"xxx" /builddefinition:"xxx1" }
Upvotes: 2