次の方法で共有


Restart-SCJob

Restart-SCJob

Restarts a failed or canceled VMM job.

Syntax

Parameter Set: Default
Restart-SCJob [-Job] <Task> [-Credential <VMMCredential> ] [-OnBehalfOfUser <System.String> ] [-OnBehalfOfUserRole <Microsoft.SystemCenter.VirtualMachineManager.UserRole> ] [-SkipLastFailedStep] [ <CommonParameters>]

Detailed Description

The Restart-SCJob cmdlet restarts one or more Virtual Machine Manager (VMM) jobs that have failed or that have been canceled by a user. Jobs that are currently running must be canceled before they can be restarted. All restarted jobs start from the last known good checkpoint before a failure or a cancellation. Some jobs have only a single checkpoint.

Restarting a job displays the object properties of the job to the user and shows the Status property as Running.

Parameters

-Credential<VMMCredential>

Specifies a credential object or, for some cmdlets, a Run As account object that contains the user name and password of an account that has permission to perform this action. Or, in the case of Restart-SCJob, has permission to complete a restarted task.

For more information about the PSCredential object, type Get-Help Get-Credential. For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-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

-OnBehalfOfUser<System.String>

For more information about the PSCredential object, type Get-Help Get-Credential. For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-OnBehalfOfUserRole<Microsoft.SystemCenter.VirtualMachineManager.UserRole>

For more information about the PSCredential object, type Get-Help Get-Credential. For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SkipLastFailedStep

Indicates that the last step that failed will not be rerun when a job is restarted.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

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.

  • Job

Notes

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

Examples

Example 1: Restart all jobs that were cancelled on a specific virtual machine

The first command gets the Run As account object named RunAsAccount01, and then stores the object in the $Creds variable.

The second command gets all VMM jobs from the VMM database, selects only jobs on virtual machine VM01 that have been cancelled, and then passes each object to the Restart-Job cmdlet, which restarts the jobs using the Run As account supplied in $Creds.

PS C:\> $Creds = Get-SCRunAsAccount -Name "RunAsAccount01"
PS C:\> Get-SCJob | where { $_.ResultName -eq "VM01" -and $_.Status -eq "Canceled" } | Restart-SCJob -Credential $Creds

Example 2: Restart a specific job

The first command gets the Run As account object named RunAsAccount01, and then stores the object in the $Creds variable.

The second command gets the VMM job object with ID cb3a0f0a-9fbc-4bd0-a999-3fae8cd77177, and then restarts that job using the Run As account supplied in $Creds.

PS C:\> $Creds = Get-SCRunAsAccount -Name "RunAsAccount01"
PS C:\> Get-SCJob -ID "cb3a0f0a-9fbc-4bd0-a999-3fae8cd77177" | Restart-SCJob -Credential $Creds

Find-SCJob

Get-SCJob

Stop-SCJob

Get-SCRunAsAccount