Move-SCVirtualHardDisk

Moves a virtual hard disk file from one location to another on the same host or, when used with Move-SCVirtualMachine, to a location on a different host.

Description

The Move-SCVirtualHardDisk cmdlet moves a Windows-based virtual hard disk file (a .vhd file) or a VMware-based virtual hard disk file (a .vmdk file) from one location to another on the same host. You can also use Move-SCVirtualHardDisk with the Move-SCVirtualMachine cmdlet to move a virtual hard disk file to a location on a different host.

You can use this cmdlet to perform the following tasks: 

- Move a virtual hard disk on a running VMware virtual machine
  with no service interruption.

- Move a virtual hard disk on a running Windows Server 2008 R2 
  or greater virtual machine with minimal service interruption. 
  In this case, use Move-SCVirtualHardDisk with Move-SCVirtualMachine.

- Move a virtual hard disk on a virtual machine on any type 
  of host if the virtual machine is in a stopped state or in 
  a saved state. In this case, use Move-SCVirtualHardDisk with 
  Set-SCVirtualMachine. This option is supported if either of the 
  following conditions are true:

  - The virtual machine is on a host that uses Windows Server 
	2008 R2 or greater Hyper-V technology or on a VMware ESX host, 
	and the virtual machine is in a saved state or in a stopped state.

  - The virtual machine is on any other supported host, and it 
	is in a stopped state.

Usage examples: 

- If a host has multiple physical disk drives and the virtual machine
  has two virtual hard disks (one disk might contain the operating system 
  and the other disk might contain data), you can use this cmdlet to move 
  one of the virtual hard disks to a different physical hard drive in order 
  to improve performance for both virtual hard disks.

- If the virtual machine has one dynamically expanding virtual hard disk
  and you discover that the virtual hard disk has expanded to a point where
  it uses most of the space on its current physical hard disk on the host,
  you can use this cmdlet to move the expanded virtual hard disk to a
  larger physical hard disk if one is available on the host.

For more information about Move-SCVirtualHardDisk, type: "Get-Help Move-SCVirtualHardDisk -online".

Parameters

Bus

Required? true
Accept Pipeline Input? false
Position? named
Specifies the IDE bus to which to attach a virtual disk drive or virtual DVD drive, or the SCSI bus to which to attach a virtual disk drive. 

Example format: -IDE -Bus 1 -LUN 0
Example format: -SCSI -Bus 0 -LUN 1

NOTE: See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

IDE

Required? true
Accept Pipeline Input? false
Position? named
Specifies IDE as the bus type to which to attach a virtual disk drive object or a virtual DVD drive object configured on a virtual machine or on a template.

Example format: -IDE –Bus 0 –LUN 1 

JobGroup

Required? true
Accept Pipeline Input? false
Position? named
Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identifier runs. 

LUN

Required? true
Accept Pipeline Input? false
Position? named
Specifies the logical unit number (LUN) for a virtual disk drive object or for a virtual DVD drive object on an IDE bus, or for a virtual disk drive object on a SCSI bus. 

Example format: -IDE -Bus 1 -LUN 0
Example format: -SCSI -Bus 0 -LUN 1

Path

Required? true
Accept Pipeline Input? false
Position? named
Specifies the destination path for the operation.

Example formats:
 Local path	 -Path "F:\"
 UNC path		 -Path "\\Library\Templates"
 Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"
 VMware ESX path  –Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"
 Citrix XenServer path - Path “Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]”

Wildcards are supported for "Get" cmdlets and when you specify the UNC path:

Example format:
 UNC path		 -Path "\\VMHostServer\MyVMs\*VM*"

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.

Bus

Required? true
Accept Pipeline Input? false
Position? named
Specifies the IDE bus to which to attach a virtual disk drive or virtual DVD drive, or the SCSI bus to which to attach a virtual disk drive. 

Example format: -IDE -Bus 1 -LUN 0
Example format: -SCSI -Bus 0 -LUN 1

NOTE: See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

JobGroup

Required? true
Accept Pipeline Input? false
Position? named
Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identifier runs. 

LUN

Required? true
Accept Pipeline Input? false
Position? named
Specifies the logical unit number (LUN) for a virtual disk drive object or for a virtual DVD drive object on an IDE bus, or for a virtual disk drive object on a SCSI bus. 

Example format: -IDE -Bus 1 -LUN 0
Example format: -SCSI -Bus 0 -LUN 1

Path

Required? true
Accept Pipeline Input? false
Position? named
Specifies the destination path for the operation.

Example formats:
 Local path	 -Path "F:\"
 UNC path		 -Path "\\Library\Templates"
 Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"
 VMware ESX path  –Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"
 Citrix XenServer path - Path “Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]”

Wildcards are supported for "Get" cmdlets and when you specify the UNC path:

Example format:
 UNC path		 -Path "\\VMHostServer\MyVMs\*VM*"

SCSI

Required? true
Accept Pipeline Input? false
Position? named
Specifies SCSI as the bus type to which to attach a virtual disk drive object configured on a virtual machine or on a template. 

Example format: -SCSI -Bus 0 -LUN 0

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.

VirtualHardDisk

Required? true
Accept Pipeline Input? true (ByValue)
Position? 0
Specifies a virtual hard disk object.

JobGroup

Required? true
Accept Pipeline Input? false
Position? named
Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identifier runs. 

Path

Required? true
Accept Pipeline Input? false
Position? named
Specifies the destination path for the operation.

Example formats:
 Local path	 -Path "F:\"
 UNC path		 -Path "\\Library\Templates"
 Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"
 VMware ESX path  –Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"
 Citrix XenServer path - Path “Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]”

Wildcards are supported for "Get" cmdlets and when you specify the UNC path:

Example format:
 UNC path		 -Path "\\VMHostServer\MyVMs\*VM*"

JobVariable

Required? false
Accept Pipeline Input? false
Position? named
Specifies that job progress is tracked and stored in the variable named by this parameter. 

PROTipID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

RunAsynchronously

Required? false
Accept Pipeline Input? false
Position? named
Indicates that the job runs asynchronously so that control returns to the command shell immediately. 

Examples

1: Move a virtual hard disk file from one location to another on the same host.
PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> $VHD = $VM.VirtualHardDisks[0]
PS C:\> Move-SCVirtualHardDisk -VirtualHardDisk $VHD -Path "C:\VHDs"
The first command gets the virtual machine object named VM01 and stores the object in the $VM variable.

The second command stores the first virtual hard disk object on VM01 in the $VHD variable.

The last command moves the virtual hard disk stored in $VHD to the existing folder "C:\VHDs".

See Also