user1161137
user1161137

Reputation: 1117

Can you custom name a job?

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

Answers (1)

briantist
briantist

Reputation: 47812

Yes, use the -Name parameter.

Start-Job -Name MyName -ScriptBlock { tfsbuild start /collection:"xxx" /builddefinition:"xxx1" }

Start-Job Documentation

Upvotes: 2

Related Questions