Stop-SCJob

Stop-SCJob

Stops running VMM jobs.

Syntax

Parameter Set: Default
Stop-SCJob [-Job] <Task> [ <CommonParameters>]

Detailed Description

The Stop-SCJob cmdlet stops one or more Virtual Machine Manager (VMM) jobs that are running, and returns the object for each job in a stopped state. If the VMM job is not currently running, this cmdlet has no effect.

Parameters

-Job<Task>

Specifies a VMM job object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • Task

Notes

  • Requires a VMM job object, which can be retrieved by using the Get-SCJob cmdlet.

Examples

1: Stop all currently running jobs.

The first command gets all VMM job objects, passes each job object to the "where" filter to select only the jobs that are currently running, and stores the objects in the $Job object array.

The second command passes each object in $Job to the Stop-Job cmdlet, which stops each running job.

PS C:\> $Job = Get-SCJob | where { $_.Status -eq "Running" }
PS C:\> $Job | Stop-SCJob

2: Stop a specific running job asynchronously.

The first command gets all VMM job objects and, from the results, selects only the job on VM01 identified by job ID cb3a0f0a-9fbc-4bd0-a999-3fae8cd77177, and then stores thie object in the $Job variable.

The second command stops the job and returns the stopped job object to the user.

PS C:\> $Job = Get-SCJob | where { $_.ResultName -eq "VM01" -and $_.ID -eq "cb3a0f0a-9fbc-4bd0-a999-3fae8cd77177" }
PS C:\> Stop-SCJob -Job $Job

Find-SCJob

Get-SCJob

Restart-SCJob