Skip to content

Add-SpectreJob

Synopsis

Adds a Spectre job to a list of jobs.


Description

This function adds a Spectre job to the list of jobs you want to wait for with Wait-SpectreJobs.


Examples

This is an example of how to use the Add-SpectreJob function to add two jobs to a jobs list that can be passed to Wait-SpectreJobs.

Invoke-SpectreCommandWithProgress -Title "Waiting" -ScriptBlock {
    param (
        $Context
    )
    $jobs = @()
    $jobs += Add-SpectreJob -Context $Context -JobName "job 1" -Job (Start-Job { Start-Sleep -Seconds 5 })
    $jobs += Add-SpectreJob -Context $Context -JobName "job 2" -Job (Start-Job { Start-Sleep -Seconds 10 })
    Wait-SpectreJobs -Context $Context -Jobs $jobs
}

Parameters

Context

The Spectre context to add the job to. The context object is only available inside Wait-SpectreJobs. https://spectreconsole.net/api/spectre.console/progresscontext/

TypeRequiredPositionPipelineInput
[Object]true1false

JobName

The name of the job to add.

TypeRequiredPositionPipelineInput
[String]true2false

Job

The PowerShell job to add to the context.

TypeRequiredPositionPipelineInput
[Job]true3false

Syntax

Add-SpectreJob [-Context] <Object> [-JobName] <String> [-Job] <Job> [<CommonParameters>]