共用方式為


Stop-SCJob

Stops running VMM jobs.

Syntax

Default (Default)

Stop-SCJob
    [-Job] <Task>
    [-OnBehalfOfUser <String>]
    [-OnBehalfOfUserRole <UserRole>]
    [<CommonParameters>]

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.

Examples

Example 1: Stop all currently running jobs

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

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-SCJob cmdlet, which stops each running job.

Example 2: Stop a specific running job asynchronously

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

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.

Parameters

-Job

Specifies a VMM job object.

Parameter properties

Type:Task
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-OnBehalfOfUser

Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-OnBehalfOfUserRole

Specifies a user role. To obtain a user role, use the Get-SCUserRole cmdlet. This cmdlet operates on behalf of the user role that this parameter specifies.

Parameter properties

Type:UserRole
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Outputs

Task

This cmdlet returns a Task object.

Notes

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