Restart-SCJob

Restarts a failed or canceled VMM job.

Description

The Restart-SCJob cmdlet restarts one or more System Center 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”.

For more informatoin about Restart-SCJob, type: "Get-Help Restart-Job -online".

Parameters

Job

Required? true
Accept Pipeline Input? true (ByValue)
Position? 0
Specifies a VMM job object.

Credential

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
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".

SkipLastFailedStep

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the last step that failed will not be rerun when a job is restarted.
Requires a Virtual Machine Manager job, which can be retrieved by using the Get-SCJob cmdlet.

Examples

1: Restart all jobs that were cancelled on a specific virtual machine.
PS C:\> $Creds = Get-SCRunAsAccount -Name "RunAsAccount01"
PS C:\> Get-SCJob | where { $_.ResultName -eq "VM01" -and $_.Status -eq "Canceled" } | Restart-SCJob -Credential $Creds
The first command gets the Run As account object named RunAsAccount01 and 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.
2: Restart a specific job.
PS C:\> $Creds = Get-SCRunAsAccount -Name "RunAsAccount01"
PS C:\> Get-SCJob -ID "cb3a0f0a-9fbc-4bd0-a999-3fae8cd77177" | Restart-SCJob -Credential $Creds
The first command gets the Run As account object named RunAsAccount01 and stores the object in the $Creds variable.

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

See Also