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>]Related Commands
Online versionDetailed 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
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| VMHost | VMHost | Specify the host on which you want to create the new virtual machine. | true | true (ByValue) | |
| Template | Template | Specify 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. | true | true (ByValue) | |
| AlternateGuestName | String | Specify the full OS name of the new virtual machine. Use this parameter if the GuestID parameter is set to otherGuest or otherGuest64. | false | false | |
| CD | SwitchParameter | Indicate that you want to add a CD drive to the new virtual machine. | false | false | |
| Confirm | SwitchParameter | If 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. | false | false | $true |
| Datastore | Datastore | Specify the datastore where you want to place the new virtual machine. | false | false | |
| Description | String | Provide a description of the new virtual machine. The alias of this parameter is Notes. | false | false | |
| DiskMB | Int64[] | Specify the size in MB of the disks that you want to create and add to the new virtual machine. | false | false | 4096 |
| DiskPath | String[] | Specify paths to virtual disks you want to add to the new virtual machine. | false | false | |
| DiskStorageFormat | VirtualDiskStorageFormat | Specify the storage format of the disks of the virtual machine. The valid values are Thin and Thick. | false | false | |
| DrsAutomationLevel | DrsAutomationLevel | Specify 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. | false | false | |
| Floppy | SwitchParameter | Indicate that you want to add a floppy drive to the new virtual machine. | false | false | |
| GuestId | String | Specify 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. | false | false | |
| HAIsolationResponse | HAIsolationResponse | Indicates 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. | false | false | |
| HARestartPriority | HARestartPriority | Specify 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. | false | false | |
| Location | Folder | Specify the folder where you want to place the new virtual machine. | false | false | |
| MemoryMB | Int64 | Specify the memory size in MB of the new virtual machine. | false | false | 256 |
| Name | String | Specify a name for the new virtual machine. If you are registering or cloning an existing virtual machine, this parameter is not mandatory. | true | false | |
| NetworkName | String[] | Specify the networks to which you want to connect the new virtual machine. | false | false | |
| NumCpu | Int32 | Specify the number of the virtual CPUs of the new virtual machine. | false | false | 1 |
| OSCustomizationSpec | OSCustomizationSpec | Specifies a customization specification that is to be applied to the new virtual machine. | false | false | |
| ResourcePool | ResourcePool | Specify 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. | false | true (ByValue) | |
| RunAsync | SwitchParameter | Indicate 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. | false | false | |
| Server | VIServer[] | 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. | false | false | |
| VApp | VApp | Specify the virtual appliance where you want to create the new virtual machine. | false | true (ByValue) | |
| Version | VMVersion | Specify 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. | false | false | |
| VM | VirtualMachine[] | Specify a virtual machine to clone. | true | true (ByValue) | |
| VMFilePath | String | Specify a path to the virtual machine you want to register. | true | false | |
| VMSwapfilePolicy | VMSwapfilePolicy | Specify 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.. | false | false | |
| WhatIf | SwitchParameter | Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified. | false | false |
Return Type
VirtualMachineNotes
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.