Repair-SCVirtualMachine

Repairs a virtual machine in a failed state.

Syntax

Repair-SCVirtualMachine
      [-VM] <VM>
      [-Dismiss]
      [-Force]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-OnBehalfOfUser <String>]
      [-OnBehalfOfUserRole <UserRole>]
      [<CommonParameters>]
Repair-SCVirtualMachine
      [-VM] <VM>
      [-Undo]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-OnBehalfOfUser <String>]
      [-OnBehalfOfUserRole <UserRole>]
      [<CommonParameters>]
Repair-SCVirtualMachine
      [-VM] <VM>
      [-Retry]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-OnBehalfOfUser <String>]
      [-OnBehalfOfUserRole <UserRole>]
      [<CommonParameters>]
Repair-SCVirtualMachine
      [-VM] <VM>
      [-Agent]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-OnBehalfOfUser <String>]
      [-OnBehalfOfUserRole <UserRole>]
      [<CommonParameters>]
Repair-SCVirtualMachine
      [-VM] <VM>
      [-MigrateDBOnlyVM]
      -VMHost <Host>
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-OnBehalfOfUser <String>]
      [-OnBehalfOfUserRole <UserRole>]
      [<CommonParameters>]

Description

The Repair-SCVirtualMachine cmdlet repairs a virtual machine in a failed state that is on a host managed by Virtual Machine Manager (VMM). A virtual machine can be in one of the following types of failed state:

  • Creation Failed
  • Migration Failed
  • Update Failed
  • Deletion Failed

You can use this command to repair a failure as follows:

  • Retry. Tries to perform the failed job again.
  • Undo. Try to undo any changes that were made to the virtual machine and restore it to a healthy state. For example, if a Move-SCVirtualMachine job fails, Undo tries to move the virtual machine back to its previous host.
  • Dismiss. Dismisses the failed job and updates the virtual machine based on its current state. If you manually fix a failure, you can use the Dismiss option to refresh the data for the virtual machine in the VMM database. However, using the Dismiss option might return the object to the failed state.

When you run this cmdlet, you can specify only one type of action at a time.

You can run this cmdlet to repair an in-guest agent for a virtual machine that is part of a service by using the Agent parameter.

Examples

Example 1: Repair a failed migration task by retrying the migration task

PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> Repair-SCVirtualMachine -VM $VM -Retry

The first command gets the virtual machine object named VM01, and then stores that object in the $VM variable. In this example, you want to repair a failed move action.

The second command repairs the virtual machine object stored in $VM by restarting the previous failed migration task.

Example 2: Repair or upgrade the VMM In-guest agent on a specified virtual machine that is part of a service

PS C:\> $VM = Get-SCVirtualMachine -Name "ServiceVM01"
PS C:\> $Creds = Get-Credential
PS C:\> Repair-SCVirtualMachine -VM $VM -Credential $Creds -Agent

The first command gets the virtual machine object named ServiceVM01, and then stores that object in the $VM variable. In this example, the virtual machine is part of a service.

The second command gets a credential object, which must be a local administrator on the virtual machine to be repaired, and then stores that object in the $Creds variable.

The third command repairs the in-guest agent on the virtual machine object stored in $VM.

Parameters

-Agent

Indicates that this cmdlet repairs or upgrades the VMM in-guest agent, as applicable.

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

-Dismiss

Dismisses the error on an object or an update notification on a service instance.

After an error is dismissed, the object is refreshed. If the error reappears, refreshing does not solve the problem and you must fix the error.

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

-Force

Forces the operation to finish.

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

-JobVariable

Specifies the name of a variable for job progress.

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

-MigrateDBOnlyVM

Indicates that this cmdlet uses MigrateDBOnlyVM.

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

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

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

-Retry

Indicates that this cmdlet retries the last task that failed on the virtual machine in an attempt to complete the task successfully.

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

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

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

-Undo

Indicates that this cmdlet cancels the last job run on the virtual machine and reverses any changes that were made. This parameter is available only if the most recent job failed.

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

-VM

Specifies a virtual machine object.

Type:VM
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMHost

Specifies a virtual machine host object. VMM supports Hyper-V hosts, VMware ESX hosts, and Citrix XenServer hosts. For more information about each type of host, see the Add-SCVMHost cmdlet.

Type:Host
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Outputs

VirtualMachine

Notes

  • This cmdlet requires a virtual machine object, which can be retrieved by using the Get-SCVirtualMachine cmdlet.