Get PowerShell background jobs that are running in the current session.

      Get-Job [-Command string[]] [CommonParameters]

      Get-Job [[-InstanceId] Guid[]] [CommonParameters]

      Get-Job [[-Name] string[]] [CommonParameters]

      Get-Job [[-Id] Int32[]] [CommonParameters]

      Get-Job [-State {NotStarted | Running | Completed | Failed | Stopped | Blocked}] [CommonParameters]

   -Command string[]
       Get the jobs that include the specified command.
       The default is all jobs. Enter a command (as a string).
       You can use wildcards to specify a command pattern.

    -Id Int32[]
       Get only jobs with the specified IDs. 

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

   -InstanceId Guid[]
       Get jobs with the specified instance IDs. The default is all jobs.

       An instance ID is a GUID that uniquely identifies the job on the computer.
       To find the instance ID of a job, use Get-Job.

   -Name string[]
       Get the job with the specified friendly names.
       Enter a job name, or use wildcard characters to enter a job name pattern.
       By default, Get-Job gets all jobs in the current session.

   -State JobState
       Get only jobs in the specified state.
       Valid values are NotStarted, Running, Completed, Stopped, Failed, and Blocked.
       By default, Get-Job gets all the jobs in the current session.

Standard Aliases for Get-Job: gjb

Use Get-Job to get jobs that were started by using Start-Job, or by using the AsJob parameter of any cmdlet. A PowerShell background job is a command that runs "in the background" without interacting with the current session. Typically, you use a background job to run a complex command that takes a long time to complete. For more information see about_Jobs.


Get all background jobs started in the current session:

PS C:\> get-job

Stop a job using its unique ID:

PS C:\> $myjob = get-job -name Job1
PS C:\> $jobid = $myjob.InstanceID
PS C:\> stop-job -instanceid $jobid

Get jobs on the system that include a Get-Process command:

PS C:\> get-job -command "*get-process*"
PS C:\> "*get-process*" | get-job

Get jobs that have been created but have not yet been started. (including scheduled jobs):

PS C:\> get-job -state NotStarted

“New York is an exciting town where something is happening all the time, most unsolved” ~ Johnny Carson

Related PowerShell Cmdlets

Receive-Job - Get PowerShell background job results.
Remove-Job - Delete a PowerShell background job.

Copyright © 1999-2024
Some rights reserved