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
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
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.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Agent
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
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.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Dismiss
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Force
Forces the operation to finish.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Dismiss
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-JobVariable
Specifies the name of a variable for job progress.
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
-MigrateDBOnlyVM
Indicates that this cmdlet uses MigrateDBOnlyVM.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
MigrateDBOnlyVM
Position:
Named
Mandatory:
True
Value from pipeline:
False
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
-PROTipID
Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action.
This parameter lets you audit PRO tips.
Parameter properties
Type:
Guid
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
-Retry
Indicates that this cmdlet retries the last task that failed on the virtual machine in an attempt to complete the task successfully.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Retry
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-RunAsynchronously
Indicates that the job runs asynchronously so that control returns to the command shell immediately.
Parameter properties
Type:
SwitchParameter
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
-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.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Undo
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-VM
Specifies a virtual machine object.
Parameter properties
Type:
VM
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
-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.
Parameter properties
Type:
Host
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
MigrateDBOnlyVM
Position:
Named
Mandatory:
True
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
VirtualMachine
Notes
This cmdlet requires a virtual machine object, which can be retrieved by using the Get-SCVirtualMachine cmdlet.