Previous Topic: dpmhv-createVM (Funclet) Command--Create a VMNext Topic: dpmhv-createVMFromTemplateEx (Funclet) Command--Create a VM Using a Template


dpmhv-createVMFromTemplate (Funclet) Command--Create a VM Using a Template

The dpmhv-createVMFromTemplate command creates a VM from a previously created Microsoft System Center Virtual Machine Manager (SCVMM) template and optionally customizes settings for Windows images.

The template is left untouched, so that a single template can be used to create any number of virtual machines. The command supports (SCVMM) hosted templates only. See dpmhv-createVMFromTemplateEx for local template support without SCVMM.

This command has the following format:

dpmhv-createVMFromTemplate 
-host hostname 
-vm vmname 
-template templatename 
-dest pathname
-scvmmHost  scvmmHostname
-adminPass adminPW
[-computerName computerName] 
[-ip4addr ip4addr] 
[-ip4dhcp ip4dhcpInt] 
[-ip4mask ip4mask] 
[-ip4gw ip4gw]
[-ip4metric ip4metric] 
[-ip4dns ip4dns]
[-productKey key]
[-userName UserName]
[-organization orgname] 
[-domain domainname] 
[-domainAdmin domad] 
[-domainAdminPass dompw] 
[-workgroup wgname] 
[-adminUser adminUser] 
[-adminUserPass adminUserPW]
[-mem mem]
[-cpus cpus]
[-hardwareProf hwprof]
[-guestOSProf osprof]
[-startVM]
-host hostname

Specifies the name of the Hyper-V server host.

-vm vmname

Specifies the name of the VM.

-template templatename

Specifies the name of the source template that you want to use to create the VM.

Note: The template name must be unique in the local template catalog.

-dest pathname

(Optional) Specifies the path of the VM that you want to create (template is stored). If this option is not specified, VM is created in the Hyper-V Server default location. The name of the template created is stored in the following location: %ALLUSERSPROFILE%\ca\vpm\Hyper-V_Templates.

Note: We recommend not creating VMs in the Hyper-V default location. It conflicts with virtual disk image file names that do not change when creating VMs using templates.

-scvmmHost scvmmHostname

(Optional) Specifies the host name of the Microsoft System Center Virtual Machine Manager (SCVMM) library server. This parameter is valid when you use SCVMM integration to provision VMs.

-adminPass adminPW

(Optional) This option is used to set the default administrator account password for the VM. Support for this parameter requires a Windows image created using Sysprep tool. This parameter is ignored in asynchronous execution.

Note: To set this option successfully, set the Windows Server administrator password which is created using Sysprep tool as empty.

-computerName computerName

(Optional) Specifies the computer name of the VM. Support for this parameter requires an image using Sysprep tool. This option is invalid for asynchronous execution of the command.

-ip4addr ip4addr

(Optional) Specifies the static IPv4 address that you want to assign to an interface of the VM. To set an IP address for a specific interface, the IP address is prefixed with known interface name and '#' as separator. For example,
-ip4addr "Local Area Connection#192.168.1.200". If the template image has more than one network adaptor, the IP address is assigned to the first interface. This option is invalid for asynchronous execution of the command.

-ip4dhcp ip4dhcpInt

(Optional) Specifies an option to turn on DHCP of a particular interface of the VM. You can also specify the interface name for this option. For example,
-ip4dhcp "Local Area Connection." If the template image has more than one network adaptor, DHCP is turned on for the first interface. This option is invalid for asynchronous execution of the command.

Default: local

-ip4mask ip4mask

(Optional) Specifies the subnet mask that you want to assign for the VM. This option is used with
-ip4ddr option. If an interface name is specified in the
-ip4addr option, same interface name must be used in this option. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of the command.

-ip4gw ip4gw

(Optional) Specifies the option to set the gateway for VM. This option is used with -ip4ddr option. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

Note: If an interface name is specified in the
-ip4addr option, same interface name must be used in this option.

-ip4metric ip4metric

(Optional) Specifies the interface metric that you want to set for the VM. This option is used with -ip4ddr option. If an interface name is specified in the
-ip4addr option, same interface name must be used in this option. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

Default: 1

-ip4dns ip4dns

(Optional) Specifies the DNS server that you want to set for the VM. This option is used with -ip4ddr option. If an interface name is specified in the
-ip4addr option, same interface name must be used in this option. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-adminPass adminPW

(Optional) This option is used to set the default administrator account password for the VM. Support for this parameter requires a Windows image created using Sysprep tool. This parameter is ignored in asynchronous execution.

Note: To set this option successfully, set the Windows Server 2003 administrator password which is created using Sysprep tool as empty.

-productKey key

(Optional) Specifies the Windows product activation key for the VM. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-userName UserName

(Optional) Specifies the user name of the Windows image (created using sysprep tool) which is installed on the new VM. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-organization orgname

(Optional) Specifies the organization name of the Windows image (created using sysprep tool) which is installed on the new VM. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-domain domainname

(Optional) Specifies the domain name for the VM. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command. Domain and workgroup specifications are mutually exclusive.

-domainAdmin domad

(Optional) Specifies the user account as Domain Administrator that you want to create in the domain. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-domainAdminPass dompw

(Optional) Specifies the password for Domain Administrator user account that you want to create in the domain. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-workgroup wgname

(Optional) Specifies the workgroup that you want to create for the VM. Support for this parameter requires a Windows image created using Sysprep tool. Domain and workgroup specifications are mutually exclusive. This option is invalid for asynchronous execution of command.

-adminUser adminUser

(Optional) Specifies the administrator user name that you want to create as a part of the default Administrators group. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-adminUserPass adminUserPW

(Optional) Specifies the password of the administrator user account that you want to create as a part of the default Administrators group. Support for this parameter requires a Windows image created using Sysprep tool. This option is invalid for asynchronous execution of command.

-mem mem

(Optional) Specifies the RAM memory in megabytes (MB) for the VM that you want to create.

Default: -1

-cpus cpus

(Optional) Specifies the number of CPU cores to assign to the VM.

Default: -1

-scvmmHost scvmmHostname

(Optional) Specifies the host name of the Microsoft System Center Virtual Machine Manager (SCVMM) library server. This parameter is valid when you use SCVMM integration to provision VMs.

-hardwareProf hwprof

(Optional) Specifies the name of the hardware profile defined by the Microsoft System Center Virtual Machine Manager (SCVMM) library server. This parameter overwrites the hardware configuration settings stored in the SCVMM template. This parameter is valid when you use SCVMM integration to provision VMs.

-guestOSProf osprof

(Optional) Specifies the name of the guest operating system profile defined by the Microsoft System Center Virtual Machine Manager (SCVMM) library server. This parameter overwrites the operating system configuration settings stored in the SCVMM library server. This parameter is valid when you use SCVMM integration to provision VMs.

-startVM

(Optional) Specifies the option to start the VM automatically after it is created. By default, the new VM is in powered-off state. You must customize the IP configuration options required to start the VM.

Return Value

The dpmhv-createVMFromTemplate command returns an empty string when it is executed synchronously. If executed asynchronously, a string representing job ID is passed to dpmhv-getJobErrorInfo, dpmhv-getJobInfo, or dpmhv-getJobStatus. If an error occurs during execution, the command reports an exception.

Example: Create a VM from an SCVMM Template

This example lets you create VM from an SCVMM template with options to specify the hardware and guest OS profiles:

dpmhv-createVMFromTemplate -host hvserver -vm NewVM -dest c:\VMs\NewBox -template Win2k3Clean 
-scvmmHost SCVMMLibSrv -hardwareProf hw_def -guestOSProf os_def -async -adminPass #admin#

See also:

dpmhv-createVMFromTemplateEx (Funclet) Command--Create a VM Using a Template