vSphere PowerCLI Cmdlets Reference

New-VM

Synopsis

Creates a new virtual machine.

Syntax

New-VM [-VMHost] <VMHost> [-Version <VMVersion>] -Name <String> [-ResourcePool <ResourcePool>] [-VApp <VApp>] [-Location <Folder>] [-Datastore <Datastore>] [-DiskMB <Int64[]>] [-DiskPath <String[]>] [-DiskStorageFormat <VirtualDiskStorageFormat>] [-MemoryMB <Int64>] [-NumCpu <Int32>] [-Floppy] [-CD] [-GuestId <String>] [-AlternateGuestName <String>] [-NetworkName <String[]>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] [-VMSwapfilePolicy <VMSwapfilePolicy>] [-Server <VIServer[]>] [-RunAsync] [-Description <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-VM [-VMHost] <VMHost> -Name <String> [-ResourcePool <ResourcePool>] [-VApp <VApp>] [-Location <Folder>] [-Datastore <Datastore>] [-Template] <Template> [-DiskStorageFormat <VirtualDiskStorageFormat>] [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-Description <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-VM [-VMHost] <VMHost> [-Name <String>] [-ResourcePool <ResourcePool>] [-VApp <VApp>] [-Location <Folder>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] -VMFilePath <String> [-Server <VIServer[]>] [-RunAsync] [-Description <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-VM [-VMHost] <VMHost> [-Name <String>] [-ResourcePool <ResourcePool>] [-VApp <VApp>] [-Location <Folder>] [-Datastore <Datastore>] [-DiskStorageFormat <VirtualDiskStorageFormat>] [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-Description <String>] -VM <VirtualMachine[]> [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-VM
Move-VM
Remove-VM
Set-VM
Start-VM
Stop-VM
Suspend-VM
Restart-VM

Detailed Description

Creates a new virtual machine with the provided parameters. The network adapter and the SCSI adapter of the new virtual machine are created of the recommended type for the OS that is specified by the GuestId parameter. If the OSCustomizationSpec parameter is used, the virtual machine is customized according to the spec.

Parameters

NameDescriptionRequired?Pipeline InputDefault Value
VMHostSpecify the host on which you want to create the new virtual machine.truetrue (ByValue)
VersionSpecify the version of the new virtual machine. The valid values are v4 and v7. By default, the new virtual machine is created with the highest available version.falsefalse
NameSpecify a name for the new virtual machine. If you are registering or cloning an existing virtual machine, this parameter is not mandatory.truefalse
ResourcePoolSpecify the resource pool where you want to place the new virtual machine. If not specified, the virtual machine is added to the resource pool of its host.falsetrue (ByValue)
VAppSpecify the virtual appliance where you want to create the new virtual machine.falsetrue (ByValue)
LocationSpecify the folder where you want to place the new virtual machine.falsefalse
DatastoreSpecify the datastore where you want to place the new virtual machine.falsefalse
DiskMBSpecify the size in MB of the disks that you want to create and add to the new virtual machine.falsefalse4096
DiskPathSpecify paths to virtual disks you want to add to the new virtual machine.falsefalse
DiskStorageFormatSpecify the storage format of the disks of the virtual machine. The valid values are Thin and Thick.falsefalse
MemoryMBSpecify the memory size in MB of the new virtual machine.falsefalse256
NumCpuSpecify the number of the virtual CPUs of the new virtual machine.falsefalse1
FloppyIndicate that you want to add a floppy drive to the new virtual machine.falsefalse
CDIndicate that you want to add a CD drive to the new virtual machine.falsefalse
GuestIdSpecify the guest operating system of the new virtual machine. See below the valid values for the various ESX versions. Depending on the hardware configuration of the host, some of the guest operating systems might be inapplicable.

For ESX servers older than ESX 4.0, the following values are valid:

darwinGuest (Darvin), dosGuest (MS-DOS), freebsd64Guest (FreeBSD x64), freebsdGuest (FreeBSD), mandrake64Guest (Mandrake Linux 64 bit), mandrakeGuest (Mandrake Linux), netware4Guest (Novell NetWare 4), netware4Guest (Novell NetWare 4), netware6Guest (Novell NetWare 6.x), nld9Guest (Novell Linux Desktop 9), oesGuest (Open Enterprise Server), os2Guest (OS/2), other24xLinux64Guest (Linux 2.4x Kernel (64 bit) (experimental)), other24xLinuxGuest (Linux 2.4x Kernel), other26xLinux64Guest (Linux 2.6x Kernel (64 bit) (experimental)), other26xLinuxGuest (Linux 2.6x Kernel), otherGuest (Other Operating System), otherGuest64 (Other Operating System (64 bit) (experimental)), otherLinux64Guest (Linux (64 bit) (experimental)), otherLinuxGuest (Other Linux), redhatGuest (Red Hat Linux 2.1), rhel2Guest (Red Hat Enterprise Linux 2), rhel3_64Guest (Red Hat Enterprise Linux 3 64 bit), rhel3Guest (Red Hat Enterprise Linux 3), rhel4_64Guest (Red Hat Enterprise Linux 4 64 bit), rhel4Guest (Red Hat Enterprise Linux 4), rhel5_64Guest (Red Hat Enterprise Linux 5 (64 bit) (experimental)), rhel5Guest (Red Hat Enterprise Linux 5), sjdsGuest (Sun Java Desktop System), sles10_64Guest (Suse Linux Enterprise Server 10 (64 bit) (expeimental)), sles10Guest (Suse linux Enterprise Server 10), sles64Guest (Suse Linux Enterprise Server 9 64 bit), slesGuest (Suse Linux Enterprise Server 9), solaris10_64Guest (Solaris 10 (64 bit) (experimental)), solaris10Guest (Solaris 10 (32 bit) (experimental)), solaris6Guest (Solaris 6), solaris7Guest (Solaris 7), solaris8Guest (Solaris 8), solaris9Guest (Solaris 9), suse64Guest (Suse Linux (64 bit)), suseGuest (Suse Linux), turboLinuxGuest (Turbolinux), ubuntu64Guest (Ubuntu Linux 64 bit), ubuntuGuest (Ubuntu Linux), win2000AdvServGuest (Windows 2000 Advanced Server), win2000ProGuest (Windows 2000 Professional), win2000ServGuest (Windows 2000 Server), win31Guest (Windows 3.1), win95Guest (Windows 95), win98Guest (Windows 98), winLonghorn64Guest (Windows Longhorn 64 b
it (experimental)), winMeGuest (Windows Millenium Edition), winNetBusinessGuest (Windows Small Business Server 2003), winNetDatacenter64Guest (Windows Server 2003, Datacenter Edition (64 bit) (experimental)), winNetDatacenterGuest (Windows Server 2003, Datacenter Edition), winNetStandard64Guest (Windows Server 2003, Standard Edition (64 bit)), winNetStandardGuest (Windows Server 2003, Standard Edition), winNetWebGuest (Windows Server 2003, Web Edition), winNTGuest (Windows NT 4), winVista64Guest (Windows Vista 64 bit), winVistaGuest (Windows Vista), winXPHomeGuest (Windows XP Home Edition), winXPPro64Guest (Windows XP Professional Edition 64 bit), winXPProGuest (Windows XP Professional).

For ESX 4.0 and later, the following values are valid:

asianux3_64Guest (Asianux Server 3 64 bit), asianux3Guest (Asianux Server 3), asianux4_64Guest (Asianux Server 4 64 bit), asianux4Guest (Asianux Server 4), darwin64Guest (Darwin 64 bit), darwinGuest (Darwin), debian4_64Guest (Debian GNU/Linux 4 64 bit), debian4Guest (Debian GNU/Linux 4), debian5_64Guest (Debian GNU/Linux 5 64 bit), debian5Guest (Debian GNU/Linux 5), dosGuest (MS-DOS), freebsd64Guest (FreeBSD x64), freebsdGuest (FreeBSD), mandrivaGuest (Mandriva Linux), netware4Guest (Novell NetWare 4), netware5Guest (Novell NetWare 5.1), netware6Guest (Novell NetWare 6.x), nld9Guest (Novell Linux Desktop 9), oesGuest (Open Enterprise Server), openServer5Guest (SCO OpenServer 5), openServer6Guest (SCO OpenServer 6), os2Guest (OS/2), other24xLinux64Guest (Linux 2.4x Kernel (64 bit) (experimental)), other24xLinuxGuest (Linux 2.4x Kernel), other26xLinux64Guest (Linux 2.6x Kernel (64 bit) (experimental)), other26xLinuxGuest (Linux 2.6x Kernel (64 bit) (experimental)), other26xLinuxGuest (Linux 2.6x Kernel), otherGuest (Other Operating System), otherGuest64 (Other Operating System (64 bit) (experimental)), otherLinux64Guest (Linux (64 bit) (experimental)), otherLinuxGuest (Other Linux), redhatGuest (Red Hat Linux 2.1), rhel2Guest (Red Hat Enterprise Linux 2), rhel3_64Guest (Red Hat Enterprise Linux 3 (64 bit)), rhel3Guest (Red Hat Enterprise Linux 3), rhel4_64Guest (Red Hat Enterprise Linux 4 (64 bit)), rhel4Guest (Red Hat Enterprise Linux 4), rhel5_64Guest (Red Hat Enterprise Linux 5 (64 bit) (experimental)), rhel5Guest (Red Hat Enterprise Linux 5), rhel6_64Guest (Red Hat Enterprise Linux 6 (64 bit)), rhel6Guest (Red Hat Enterprise Linux 6), sjdsGuest (Sun Java Desktop System), sles10_64Guest (Suse Linux Enterprise Server 10 (64 bit) (experimental)), sles10Guest (Suse linux Enterprise Server 10), sles11_64Guest (Suse Linux Enterprise Server 11 (64 bit)), sles11Guest (Suse linux Enterprise Server 11), sles64Guest (Suse Linux Enterprise Server 9 (64 bit)), slesGuest (Suse
Linux Enterprise Server 9), solaris10_64Guest (Solaris 10 (64 bit) (experimental)), solaris10Guest (Solaris 10 (32 bit) (experimental)), solaris6Guest (Solaris 6), solaris7Guest (Solaris 7), solaris8Guest (Solaris 8), solaris9Guest (solaris 9), suse64Guest (Suse Linux (64 bit)), suseGuest (Suse Linux), turboLinux64Guest (Turbolinux (64 bit)), turboLinuxGuest (Turbolinux), ubuntu64Guest (Ubuntu Linux (64 bit)), ubuntuGuest (Ubuntu Linux), unixWare7Guest (SCO UnixWare 7), win2000AdvServGuest (Windows 2000 Advanced Server), win2000ProGuest (Windows 2000 Professional), win2000ServGuest (Windows 2000 Server), win31Guest (Windows 3.1), win95Guest (Windows 95), win98Guest (Windows 98), windows7_64Guest (Windows 7 (64 bit)), windows7Guest (Windows 7), windows7Server64Guest (Windows Server 2008 R2 (64 bit)), winLonghorn64Guest (Windows Longhorn (64 bit) (experimental)), winLonghornGuest (Windows Longhorn (experimental)), winMeGuest (Windows Millenium Edition), winNetBusinessGuest (Windows Small Business Server 2003), winNetDatacenter64Guest (Windows Server 2003, Datacenter Edition (64 bit) (experimental)), winNetDatacenterGuest (Windows Server 2003, Datacenter Edition), winNetDatacenterGuest (Windows Server 2003, Datacenter Edition), winNetDatacenterGuest (Windows Server 2003, Datacenter Edition), winNetDatacenterGuest (Windows Server 2003, Datacenter Edition), winNetEnterprise64Guest (Windows Server 2003, Enterprise Edition (64 bit)), winNetEnterpriseGuest (Windows Server 2003, Enterprise Edition), winNetStandard64Guest (Windows Server 2003, Standard Edition (64 bit)), winNetEnterpriseGuest (Windows Server 2003, Enterprise Edition), winNetStandard64Guest (Windows Server 2003, Standard Edition (64 bit)), winNetStandardGuest (Windows Server 2003, Standard Edition), winNetWebGuest (Windows Server 2003, Web Edition), winNTGuest (Windows NT 4), winVista64Guest (Windows Vista (64 bit)), winVistaGuest (Windows Vista), winXPHomeGuest (Windows XP Home Edition), winXPPro64Guest (Win
dows XP Professional Edition (64 bit)), winXPProGuest (Windows XP Professional).
falsefalse
AlternateGuestNameSpecify the full OS name of the new virtual machine. Use this parameter if the GuestID parameter is set to otherGuest or otherGuest64.falsefalse
NetworkNameSpecify the networks to which you want to connect the new virtual machine.falsefalse
HARestartPrioritySpecify the HA restart priority of the new virtual machine. The valid values are Disabled, Low, Medium, High, and ClusterRestartPriority. VMware HA is a feature that detects failed virtual machines and automatically restarts them on alternative ESX hosts. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.falsefalse
HAIsolationResponseIndicates whether the virtual machine should be powered off if a host determines that it is isolated from the rest of the compute resource. The available values are AsSpecifiedByCluster, PowerOff, and DoNothing. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.falsefalse
DrsAutomationLevelSpecify a DRS (Distributed Resource Scheduler) automation level. The valid values are valiFullyAutomated, Manual, PartiallyAutomated. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error is generated.falsefalse
VMSwapfilePolicySpecify the swapfile placement policy. The following values are valid:

InHostDataStore - Store the swapfile in the datastore specified by the VMSwapfileDatastoreID property of the virtual machine host. If the VMSwapfileDatastoreID property is not set or indicates a datastore with insufficient free space, the swapfile is stored in the same directory as the virtual machine. This setting might degrade the VMotion performance.

WithVM - Store the swapfile in the same directory as the virtual machine.

This parameter is supported only on vCenter 2.5, ESX 3.5, and later..
falsefalse
ServerSpecify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
RunAsyncIndicate that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the -RunAsync parameter run " help About_RunAsync" in the vSphere PowerCLI console.falsefalse
DescriptionProvide a description of the new virtual machine. The alias of this parameter is Notes.falsefalse
WhatIfIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse
ConfirmIf the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.falsefalse$true
TemplateSpecify the virtual machine template you want to use for the creation of the new virtual machine. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.truetrue (ByValue)
OSCustomizationSpecSpecifies a customization specification that is to be applied to the new virtual machine.falsefalse
VMFilePathSpecify a path to the virtual machine you want to register.truefalse
VMSpecify a virtual machine to clone.falsetrue (ByValue)

Return Type

VirtualMachine

Notes

Examples

-------------- Example 1 --------------

New-VM -Name VM -VMHost Host -ResourcePool ResourcePool -DiskMB 4000 -MemoryMB 256

Creates a virtual machine named VM on the Host host in the ResourcePool resource pool.

-------------- Example 2 --------------

New-Template -VM VM1 -Name Template -Location Datacenter
	
New-VM -Name VM2 -Template Template -VMHost $host

Creates the Template virtual machine template from the VM1 virtual machine. Then creates a virtual machine named VM2 based on Template .

-------------- Example 3 --------------

New-VM -VM VM1, VM2 -Location Folder -VMHost Host

Copies the VM1 and VM2 virtual machines to the Folder folder on the Host host.

-------------- Example 4 --------------

$vm2 = New-VM -Name VM2 -VM VM1 -Datastore $datastore -VMHost $host

Creates a new virtual machine named VM2 by cloning the VM1 virtual machine on the specified datastore and host.

-------------- Example 5 --------------

Get-VM VM* | New-VM -VM $vm -VMHost $host

Copies all virtual machines with names starting with "VM" on the $host host. Note that in this case, you cannot use the Name parameter to specify new names for the cloned virtual machines.

-------------- Example 6 --------------

cd vmstores:\myserver@443\Datacenter\Storage1\myvm\

$vmxFile = Get-Item *.vmx


New-VM -VMHost $host -VMFilePath $vmxFile.DatastoreFullPath

Retrieves the specified virtual machines files and registers the virtual machines on the specified host.


Copyright © 1998 - 2010 VMware, Inc. All rights reserved.