Save-SCVirtualMachine

Migrates a virtual machine deployed on a host to the VMM library.

Syntax

Save-SCVirtualMachine [-VM] <VM> [-JobVariable <String>] [-LibraryServer <LibraryServer>]
 [-OnBehalfOfUser <String>] [-OnBehalfOfUserRole <UserRole>] [-PROTipID <Guid>] [-RunAsynchronously]
 [-SharePath <String>] [-UseLAN] [<CommonParameters>]

Description

The Save-SCVirtualMachine cmdlet migrates a virtual machine deployed on a host to the Virtual Machine Manager (VMM) library.

This stores a virtual machine to the VMM library by using one of the following transfer methods:

- SAN transfer (Fibre Channel, iSCSI, or NPIV). If the host and library server are both connected to SAN storage, VMM can use a SAN transfer to store the virtual machine in the library. In a SAN transfer, the target LUNs are remapped from the source host to the destination library server. This cmdlet does not moved any files. SAN transfer is much faster than moving virtual machine files from one host to another over a local area network (LAN). VMM can use an NPIV SAN transfer if a host bus adapter (HBA) with NPIV support is available.

  • Network transfer. If no faster method is available, VMM uses a network transfer to move the virtual machine files from the host server to the library server over the LAN that connects the two servers. Specify the path of the share in the library to store the virtual machine as the SharePath parameter.

    This cmdlet automatically uses the fastest available transfer type. If you want to force a network transfer, specify the UseLAN parameter. If the host server and library server are the same server, the command does not fail if you specify UseLAN, but the migration to the library occur faster if you do not use that parameter.

    When a virtual machine is stored in the library, it cannot be started. Before you can start the virtual machine, you must move it to a host by using the Move-SCVirtualMachine cmdlet.

Examples

Example 1: Save a virtual machine to the library

PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> $LibServer = Get-SCLibraryServer -ComputerName "LibServer01"
PS C:\> Save-SCVirtualMachine -LibraryServer $LibServer -VM $VM -SharePath "\\LibServer01.Contoso.com\Library01\VMs"

The first command gets the virtual machine object named VM01, and then stores that object in the $VM variable.

The second command gets the library server object named LibServer01, and then stores that object in the $Library variable.

The last command migrates VM01 from its host and stores it to the location \LibServer01.Contoso.com\Library01\VMs. The command automatically uses the fastest available transfer type.

Example 2: Store a virtual machine in the library asynchronously

PS C:\> $VM = Get-SCVirtualMachine -Name "VM02"
PS C:\> $LibServer = Get-SCLibraryServer -ComputerName "LibServer02"
PS C:\> Save-SCVirtualMachine -LibraryServer $LibServer -VM $VM -SharePath "\\LibServer02.Contoso.com\Library02\VMs" -RunAsynchronously -JobVariable "SaveVMJob"
PS C:\> $SaveVMJob

The first command gets the virtual machine object named VM02, and then stores that object in the $VM variable.

The second command gets the library server object named LibServer02, and then stores that object in the $Library variable.

The third command migrates VM02 to the location \LibServer02.Contoso.com\Library02\VMs. The command specifies the RunAsynchronously parameter to return control to the command shell immediately. The command specifies the JobVariable parameter tracks job progress, and stores a record of its progress in $SaveVMJob. For JobVariable, you do not specify the dollar sign ($) to create the variable.

The last command displays the contents of $SaveVMJob.

Example 3: Store a virtual machine in the library by forcing a network transfer

PS C:\> $VM = Get-SCVirtualMachine -Name "VM03"
PS C:\> $LibServer = Get-SCLibraryServer -ComputerName "LibServer01"
PS C:\> Save-SCVirtualMachine -LibraryServer $LibServer -VM $VM -SharePath "\\LibServer01.Contoso.com\Library01\VMs" -UseLAN

The first command gets the virtual machine named VM03, and then stores that object in the $VM variable.

The second command gets the library server object named LibServer01, and then stores that object in the $LibServer variable.

The last command stores VM03 to the location \LibServer01.Contoso.com\Library01\VMs. The UseLAN parameter forces a network transfer over the LAN even if a faster transfer mechanism is available.

Parameters

-JobVariable

Specifies the name of a variable for job progress.

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

Specifies a VMM library server object.

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

Specifies a path to a valid library share on an existing library server where this cmdlet saves the virtual machine. Specify a Universal Naming Convention (UNC) path.

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

Indicates that this cmdlet uses transfer over the LAN even if a faster transfer mechanism is available.

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

Specifies a virtual machine object to save.

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

Outputs

VirtualMachine

This cmdlet returns a **VirtualMachine** object.

Notes

* Requires a VMM virtual machine object, which can be retrieved by using the **Get-SCVirtualMachine** cmdlet.