The Suspend-Job cmdlet suspends workflow jobs. Suspend means to temporarily interrupt or pause a workflow job. This cmdlet allows users who are running workflows to suspend the workflow. It complements the Suspend-Workflow activity, which is a command in the workflow that suspends the workflow.

The Suspend-Job cmdlet works only on workflow jobs. It does not work on standard background jobs, such as those that are started by using the Start-Job cmdlet.

To identify a workflow job, look for a value of PSWorkflowJob in the PSJobTypeName property of the job. To determine whether a particular custom job type supports the Suspend-Job cmdlet, see the help topics for the custom job type.

When you suspend a workflow job, the workflow job runs to the next checkpoint, suspends, and immediately returns a workflow job object. To wait for the suspension to complete before getting the job, use the Wait parameter of Suspend-Job or the Wait-Job cmdlet. When the workflow job is suspended, the value of the State property of the job is Suspended.

Suspending correctly relies on checkpoints. The current job state, metadata, and output are saved in the checkpoint so the workflow job can be resumed without loss of state or data. If the workflow job does not have checkpoints, it cannot be suspended correctly. To add checkpoints to a workflow that you are running, use the PSPersist workflow common parameter. You can use the Force parameter to suspend any workflow job immediately and to suspend a workflow job that does not have checkpoints, but the action could cause loss of state and data.

Before you use a Job cmdlet on a custom job type, such as a workflow job (PSWorkflowJob) import the module that supports the custom job type, either by using the Import-Module cmdlet or using or using a cmdlet in the module.

The ID is an integer that uniquely identifies the job in the current session. It is easier to remember and to type than the instance ID, but it is unique only in the current session. You can type one or more IDs, separated by commas. To find the ID of a job, use the Get-Job cmdlet.

Specifies the workflow jobs that this cmdlet stops. Enter a variable that contains the workflow jobs or a command that gets the workflow jobs. You can also pipe workflow jobs to the Suspend-Job cmdlet.

Indicates that this cmdlet suppresses the command prompt until the workflow job is in the suspended state. By default, Suspend-Job returns immediately, even if the workflow job is not yet in the suspended state.

The Wait parameter is equivalent to piping a Suspend-Job command to the Wait-Job cmdlet.

-Confirm [<SwitchParameter>]

Default value isfalse

Prompts you for confirmation before running the cmdlet.Prompts you for confirmation before running the cmdlet.

-WhatIf [<SwitchParameter>]

Default value isfalse

Shows what would happen if the cmdlet runs. The cmdlet is not run.Shows what would happen if the cmdlet runs. The cmdlet is not run.

The second command uses the AsJob parameter that is common to all workflows to run the Get-SystemLog workflow as a background job. The command uses the JobName workflow common parameter to specify a friendly name for the workflow job.

The third command uses the Get-Job cmdlet to get the Get-SystemLogJob workflow job:

This command uses the Invoke-Command cmdlet to suspend a workflow job on the Srv01 remote computer. The value of the Filter parameter is a hash table that specifies a CustomID value. This CustomID is job metadata (PSPrivateMetadata).

This command suspends the VersionCheck workflow job. The command uses the Wait parameter to wait until the workflow job is suspended. When the workflow job runs to the next checkpoint and is suspended, the command finishes and returns the job object.

Force a workflow job to suspend:

PS C:> Suspend-Job Maintenance -Force

This command suspends the Maintenance workflow job forcibly. The Maintenance job does not have checkpoints. It cannot be suspended correctly and might not resume correctly.

Additional Notes

The mechanism and location for saving a suspended job might vary depending on the job type. For example,
suspended workflow jobs are saved in a flat file store by default, but can also be saved in a database.
If you submit a workflow job that is not in the Running state, Suspend-Job displays a warning message. To
suppress the warning, use the WarningAction common parameter with a value of SilentlyContinue.
If a job is not of a type that supports suspending, Suspend-Job returns a terminating error.
To find the workflow jobs that are suspended, including those that were suspended by this cmdlet, use the
State parameter of the Get-Job cmdlet to get workflow jobs in the Suspended state.
Some job types have options or properties that prevent Windows PowerShell from suspending the job. If attempts
to suspend the job fail, verify that the job options and properties allow for suspending.