Copy-SCStorageVolume

Copies a volume of a physical hard disk on a source computer to a Windows-based virtual hard disk file (a .vhd file) on the specified VMM host.

Description

The Copy-SCStorageVolume cmdlet copies a volume of a physical hard disk on a source computer to a Windows-based virtual hard disk file (a .vhd file) on the specified System Center Virtual Machine Manager (VMM) host. If the volume contains an operating system, after you run Copy-SCStorageVolume, you must use the New-SCP2V cmdlet to configure the operating system to run in a virtual environment.

When you use Copy-SCStorageVolume with the -Offline parameter, the computer whose hard disk is to be copied is first started in the Windows Preinstallation Environment (Windows PE) and then the volumes are copied.

For more information about Copy-SCStorageVolume, type: "Get-Help Copy-SCStorageVolume -online".

Parameters

SourceComputerName

Required? true
Accept Pipeline Input? false
Position? named
Specifies the source computer for a physical-to-virtual (P2V) machine conversion performed by VMM. Valid formats: FQDN, IPv4 or IPv6 address, or NetBIOS name.

Note: See the examples for a specific cmdlet to determine how that cmdlet specifies the source computer name.

VMHost

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
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, type: "Get-Help Add-SCVMHost -detailed". See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

AddDiskSizeMB

Required? false
Accept Pipeline Input? false
Position? named
Specifies, in megabytes (MB), the amount of additional disk space to add to a virtual hard disk when performing a physical-to-virtual (P2V) or virtual-to-virtual (V2V) machine conversion. Volumes located on the virtual hard disk are automatically extended to fill the entire virtual hard disk.

Credential

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a credential object or, for some cmdlets, a Run As account object that contains the user name and password of an account that has permission to perform this action. Or, in the case of Restart-SCJob, has permission to complete a restarted task. 

For more information about the PSCredential object, type: "Get-Help Get-Credential". 
For more information about Run As accounts, type: "Get-Help New-SCRunAsAccount".

DriverPath

Required? false
Accept Pipeline Input? false
Position? named
Specifies the path to drivers for an offline physical-to-virtual machine conversion (P2V conversion).

Dynamic

Required? false
Accept Pipeline Input? false
Position? named
Specifies that a virtual hard disk can expand dynamically. 

Fixed

Required? false
Accept Pipeline Input? false
Position? named
Specifies that a virtual hard disk is fixed in size. 

JobGroup

Required? false
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. 

JobVariable

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

Offline

Required? false
Accept Pipeline Input? false
Position? named
Specifies that the operation is performed offline.

Owner

Required? false
Accept Pipeline Input? false
Position? named
Specifies the owner of a VMM object in the form of a valid domain user account.

Example format: -Owner "Contoso\ReneeLo"
Example format: -Owner "ReneeLo@Contoso"

Path

Required? false
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*"

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. 

Shutdown

Required? false
Accept Pipeline Input? false
Position? named
Indicates that a virtual machine, service, or a source server should be shut down. In the case of a virtual machine or service, the associated cmdlet attempts to use the operating system to shut the virtual machine down gracefully. In the case of a successful physical-to-virtual machine (P2V) conversion, the cmdlet shuts down the source server.

Trigger

Required? false
Accept Pipeline Input? false
Position? named
Starts running the commands in a job group for a physical-to-virtual (P2V) conversion, a virtual-to-virtual (V2V) conversion, or the conversion of a physical hard disk to a virtual hard disk.

VMMServer

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

VolumeDeviceID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the device ID of the volume to convert in a physical-to-virtual machine conversion (P2V conversion).

ComputerConfiguration

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a computer configuration object.

VMHost

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
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, type: "Get-Help Add-SCVMHost -detailed". See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.

AddDiskSizeMB

Required? false
Accept Pipeline Input? false
Position? named
Specifies, in megabytes (MB), the amount of additional disk space to add to a virtual hard disk when performing a physical-to-virtual (P2V) or virtual-to-virtual (V2V) machine conversion. Volumes located on the virtual hard disk are automatically extended to fill the entire virtual hard disk.

Credential

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a credential object or, for some cmdlets, a Run As account object that contains the user name and password of an account that has permission to perform this action. Or, in the case of Restart-SCJob, has permission to complete a restarted task. 

For more information about the PSCredential object, type: "Get-Help Get-Credential". 
For more information about Run As accounts, type: "Get-Help New-SCRunAsAccount".

DriverPath

Required? false
Accept Pipeline Input? false
Position? named
Specifies the path to drivers for an offline physical-to-virtual machine conversion (P2V conversion).

Dynamic

Required? false
Accept Pipeline Input? false
Position? named
Specifies that a virtual hard disk can expand dynamically. 

Fixed

Required? false
Accept Pipeline Input? false
Position? named
Specifies that a virtual hard disk is fixed in size. 

JobGroup

Required? false
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. 

JobVariable

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

Offline

Required? false
Accept Pipeline Input? false
Position? named
Specifies that the operation is performed offline.

Owner

Required? false
Accept Pipeline Input? false
Position? named
Specifies the owner of a VMM object in the form of a valid domain user account.

Example format: -Owner "Contoso\ReneeLo"
Example format: -Owner "ReneeLo@Contoso"

Path

Required? false
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*"

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. 

Shutdown

Required? false
Accept Pipeline Input? false
Position? named
Indicates that a virtual machine, service, or a source server should be shut down. In the case of a virtual machine or service, the associated cmdlet attempts to use the operating system to shut the virtual machine down gracefully. In the case of a successful physical-to-virtual machine (P2V) conversion, the cmdlet shuts down the source server.

Trigger

Required? false
Accept Pipeline Input? false
Position? named
Starts running the commands in a job group for a physical-to-virtual (P2V) conversion, a virtual-to-virtual (V2V) conversion, or the conversion of a physical hard disk to a virtual hard disk.

VMMServer

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

VolumeDeviceID

Required? false
Accept Pipeline Input? false
Position? named
Specifies the device ID of the volume to convert in a physical-to-virtual machine conversion (P2V conversion).
Requires a VMM computer configuration object, which can be retrieved by using the Get-SCComputerConfiguration cmdlet.

Examples

1: Copy a physical hard disk from a source machine to a virtual hard disk file.
PS C:\> $Credential = Get-Credential
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01.Contoso.com"
PS C:\> Copy-SCStorageVolume -SourceComputerName "P2VSource01.Contoso.com" -VolumeDeviceID "C" -Credential $Credential -VMHost $VMHost -Path "D:\VHDs" -Fixed -DiskSizeAdd 1024
The first command uses Get-Credential to prompt you to supply a user name and password and stores your credentials in variable $Credential. The required credentials for this operation are either a local Administrator account or a domain account with administrator rights on the computer on which resides the physical hard disk that you want to convert to a virtual hard disk. 

The second command gets the host object named VMHost01 and stores the object in the $VMHost variable.

The last command copies and converts the "C:" volume located on the source computer named P2VSource01.Contoso.com into a new virtual hard disk (still named "C:") and places it on VMHost01 at the specified path (D:\VHDs). The Fixed parameter specifies that the .vhd is fixed rather than dynamic in format, and the DiskSizeAdd parameter increases the size of the volume by 1024 MB. As this command is processed, $Credential provides your credentials to Copy-SCStorageVolume.
2: Copy a physical hard disk and configure the operating system on that volume to run in a virtual environment.
PS C:\> $Credential = Get-Credential
PS C:\> $VMHost = Get-VMHost -ComputerName "VMHost01.Contoso.com"
PS C:\> $ComputerConfig = New-SCComputerConfiguration -SourceComputerName "P2VSource.Contoso.com" -Credential $Credential
PS C:\> Copy-SCStorageVolume -SourceComputerName "P2VSource02.Contoso.com" -VolumeDeviceID "C" -Credential $Credential -VMHost $VMHost -Path "D:\VMs" -Fixed -DiskSizeAdd 1024
PS C:\> New-P2V -ComputerConfiguration $ComputerConfig -Name "VM01" -VMHost $VMHost -Path "D:\VMs" -MemoryMB 512 -Credential $Credential -RunAsynchronously
The first command uses Get-Credential to prompt you to supply a user name and password and stores your credentials in variable $Credential. The required credentials for this operation are either a local Administrator account or a domain account with administrator rights on the computer on which resides the physical hard disk that you want to convert to a virtual hard disk. 

The second command gets the host object named VMHost01 and stores the object in the $VMHost variable.

The third command gathers the computer configuration information from the physical source machine called P2VSource02.Contoso.com and stores the computer configuration information in $ComputerConfig. As this command is processed, $Credential provides your credentials to New-SCComputerConfiguration.

The fourth command copies and converts the "C:" volume located on the source computer named P2VSource02 into a new virtual hard disk (still named "C:") and places it on VMHost01 at the specified path (D:\VMs). The Fixed parameter specifies that the .vhd is fixed rather than dynamic in format, and the DiskSizeAdd parameter increases the size of the volume by 1024 MB. As this command is processed, $Credential provides your credentials to Copy-SCStorageVolume.

The last command uses the virtual hard disk located at D:\VMs on VMHost01 and the machine configuration stored in $ComputerConfig to create a new virtual machine called VM01. The New-SCP2V cmdlet automatically configures the operating system on the virtual hard disk to run in a virtual environment; it uses the -MemoryMB parameter to assign 512 MB of memory on the host for use by the virtual machine; and it uses the RunAsynchronously parameter to return control to the shell immediately, before the command completes.

See Also