Restart-SCJob

Restarts a failed or canceled VMM job.

Syntax

Restart-SCJob
       [-Job] <Task>
       [-Credential <VMMCredential>]
       [-SkipLastFailedStep]
       [-OnBehalfOfUser <String>]
       [-OnBehalfOfUserRole <UserRole>]
       [<CommonParameters>]

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.

Examples

Example 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-SCJob cmdlet, which restarts the jobs using the Run As account supplied in $Creds.

Example 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.

Required Parameters

-Job

Specifies a VMM job object.

Type:Task
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-Credential

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.

Type:VMMCredential
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-OnBehalfOfUser

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

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters: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.

Type:UserRole
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.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Outputs

Job

This cmdlet returns a Job object.

Notes

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