Copy-SCStorageVolume

Applies To: System Center 2012 - Virtual Machine Manager

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.

Syntax

Parameter Set: Install
Copy-SCStorageVolume -SourceComputerName <String> -VMHost <Host> [-AddDiskSizeMB <UInt64> ] [-Credential <PSCredential> ] [-DriverPath <String> ] [-Dynamic] [-Fixed] [-JobGroup <Guid> ] [-JobVariable <String> ] [-Offline] [-Owner <String> ] [-Path <String> ] [-PROTipID <Guid> ] [-RunAsynchronously] [-Shutdown] [-Trigger] [-VMMServer <ServerConnection> ] [-VolumeDeviceID <String> ] [ <CommonParameters>]

Parameter Set: NoInstall
Copy-SCStorageVolume -ComputerConfiguration <MachineConfiguration> -VMHost <Host> [-AddDiskSizeMB <UInt64> ] [-Credential <PSCredential> ] [-DriverPath <String> ] [-Dynamic] [-Fixed] [-JobGroup <Guid> ] [-JobVariable <String> ] [-Offline] [-Owner <String> ] [-Path <String> ] [-PROTipID <Guid> ] [-RunAsynchronously] [-Shutdown] [-Trigger] [-VMMServer <ServerConnection> ] [-VolumeDeviceID <String> ] [ <CommonParameters>]

Detailed 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

-AddDiskSizeMB<UInt64>

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerConfiguration<MachineConfiguration>

Specifies a computer configuration object.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Credential<PSCredential>

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".

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-DriverPath<String>

Specifies the path to drivers for an offline physical-to-virtual machine conversion (P2V conversion).

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Dynamic

Specifies that a virtual hard disk can expand dynamically.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Fixed

Specifies that a virtual hard disk is fixed in size.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobGroup<Guid>

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

Specifies that job progress is tracked and stored in the variable named by this parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Offline

Specifies that the operation is performed offline.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Owner<String>

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"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Path<String>

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*"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PROTipID<Guid>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

Aliases

none

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Shutdown

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SourceComputerName<String>

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.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Trigger

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMHost<Host>

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.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VMMServer<ServerConnection>

Specifies a VMM server object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-VolumeDeviceID<String>

Specifies the device ID of the volume to convert in a physical-to-virtual machine conversion (P2V conversion).

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • StorageVolume

Notes

  • 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.

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.

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

2: Copy a physical hard disk and configure the operating system on that volume to run in a virtual environment.

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.

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

Get-SCComputerConfiguration

Get-SCVMMServer

New-SCComputerConfiguration

New-SCP2V