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>] [-DiskStorageFormat <VirtualDiskStorageFormat>] [-OSCustomizationSpec <OSCustomizationSpec>] [-HARestartPriority <HARestartPriority>] [-HAIsolationResponse <HAIsolationResponse>] [-DrsAutomationLevel <DrsAutomationLevel>] [-Server <VIServer[]>] [-RunAsync] [-Description <String>] -VM <VirtualMachine[]> [-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>]

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

NameTypeDescriptionRequired?Pipeline InputDefault Value
VMHostVMHostSpecify the host on which you want to create the new virtual machine.truetrue (ByValue)
TemplateTemplateSpecify 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)
AlternateGuestNameStringSpecify the full OS name of the new virtual machine. Use this parameter if the GuestID parameter is set to otherGuest or otherGuest64.falsefalse
CDSwitchParameterIndicate that you want to add a CD drive to the new virtual machine.falsefalse
ConfirmSwitchParameterIf 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
DatastoreDatastoreSpecify the datastore where you want to place the new virtual machine.falsefalse
DescriptionStringProvide a description of the new virtual machine. The alias of this parameter is Notes.falsefalse
DiskMBInt64[]Specify the size in MB of the disks that you want to create and add to the new virtual machine.falsefalse4096
DiskPathString[]Specify paths to virtual disks you want to add to the new virtual machine.falsefalse
DiskStorageFormatVirtualDiskStorageFormatSpecify the storage format of the disks of the virtual machine. The valid values are Thin and Thick.falsefalse
DrsAutomationLevelDrsAutomationLevelSpecify a DRS (Distributed Resource Scheduler) automation level. The valid values are FullyAutomated, Manual, PartiallyAutomated, AsSpecifiedByCluster, and Disabled. 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
FloppySwitchParameterIndicate that you want to add a floppy drive to the new virtual machine.falsefalse
GuestIdStringSpecify the guest operating system of the new virtual machine. The valid values for specific ESX versions are listed in the description of the VirtualMachineGuestOsIdentifier enumeration type in the vSphere API Reference available at http://www.vmware.com/support/developer/vc-sdk/. Depending on the hardware configuration of the host, some of the guest operating systems might be inapplicable.falsefalse
HAIsolationResponseHAIsolationResponseIndicates 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
HARestartPriorityHARestartPrioritySpecify 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
LocationFolderSpecify the folder where you want to place the new virtual machine.falsefalse
MemoryMBInt64Specify the memory size in MB of the new virtual machine.falsefalse256
NameStringSpecify a name for the new virtual machine. If you are registering or cloning an existing virtual machine, this parameter is not mandatory.truefalse
NetworkNameString[]Specify the networks to which you want to connect the new virtual machine.falsefalse
NumCpuInt32Specify the number of the virtual CPUs of the new virtual machine.falsefalse1
OSCustomizationSpecOSCustomizationSpecSpecifies a customization specification that is to be applied to the new virtual machine.falsefalse
ResourcePoolResourcePoolSpecify 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)
RunAsyncSwitchParameterIndicate 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
ServerVIServer[]Specify 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
VAppVAppSpecify the virtual appliance where you want to create the new virtual machine.falsetrue (ByValue)
VersionVMVersionSpecify 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
VMVirtualMachine[]Specify a virtual machine to clone.truetrue (ByValue)
VMFilePathStringSpecify a path to the virtual machine you want to register.truefalse
VMSwapfilePolicyVMSwapfilePolicySpecify 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
WhatIfSwitchParameterIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse

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

$vm = 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.