Restore-VMSnapshot

Restores a virtual machine snapshot.

Syntax

Restore-VMSnapshot
       [-Name] <String>
       [-VMName] <String>
       [-AsJob]
       [-ComputerName <String[]>]
       [-Passthru]
Restore-VMSnapshot
       [-VM] <VirtualMachine>
       [-AsJob]
       [-Passthru]
       [-Name] <String>
Restore-VMSnapshot
       [-VMSnapshot] <VMSnapshot[]>
       [-AsJob]
       [-Passthru]

Description

The Restore-VMSnapshot cmdlet restores a virtual machine snapshot.

Examples

Example 1

PS C:\>Restore-VMSnapshot -Name 'Base image' -VMName TestVM
Confirm
Are you sure you want to perform this action?
Restore-VMSnapshot will restore snapshot "Base image".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"): Y

Restores snapshot Base image of virtual machine TestVM.

Example 2

PS C:\>Get-VM | Foreach-Object { $_ | Get-VMSnapshot | Sort CreationTime | Select -Last 1 | Restore-VMSnapshot -Confirm:$false }

Applies the most recent snapshot on all virtual machines with no confirmation prompts.

Parameters

-AsJob

Specified that the cmdlet is to be run as a background job.

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

-ComputerName

Specifies one or more Hyper-V hosts on which the virtual machine snapshot is to be restored. NetBIOS names, IP addresses, and fully-qualified domain names are allowable. The default is the local computer - use "localhost" or a dot (".") to specify the local computer explicitly.

Type:String[]
Position:Named
Default value:.
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

Specifies the name of the snapshot to be restored.

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

-Passthru

Specifies that a VMSnapshot is to be passed through to the pipeline representing the snapshot to be restored.

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

-VM

Specifies the virtual machine to be restored.

Type:VirtualMachine
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMName

Specifies the name of the virtual machine to be restored.

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

-VMSnapshot

Type:VMSnapshot[]
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Outputs

None

Default

VMSnapshot

If -PassThru is specified.