New-VM
This cmdlet creates a new virtual machine with the provided parameters. The network adapter and the Small Computer System Interface (SCSI) adapter of the new virtual machine are created of the recommended type for the operating system (OS) that is specified by the GuestId parameter. If the OSCustomizationSpec parameter is used, the virtual machine is customized according to the specification. You must specify values for at least one of the ResourcePool, VMHost, and VApp parameters.
Syntax
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
VM | VirtualMachine[] | named |
|
Specifies a virtual machine that you want to clone. |
optional | AdvancedOption | AdvancedOption[] | named |
|
Specifies advanced options for creating virtual machines. Accepts only SdrsVMDiskAntiAffinityRule and SdrsVMAntiAffinityRule objects. The SdrsVMDiskAntiAffinityRule defines a Storage DRS intra-VM anti-affinity rule (vm disk anti-affinity rule). It is only applicable when creating a virtual machine or hard disk on a datastore cluster. You can create an instance of the object by invoking its constructor. There are two constructors - "public SdrsVMDiskAntiAffinityRule(param string[] diskIdentifier)" and "public SdrsVMDiskAntiAffinityRule(param HardDisk[] disk)". For the first constructor, "diskIdentifier" can be either the disk key or the index of the disk in the disk array. The specified disks (and the disk to which the rule is applied) are placed in an anti-affinity rule on a DatastoreCluster. Only one such rule is supported per a virtual machine. You can pass the instance to the AdvancedOption parameter of the New-VM or New-HardDisk cmdlets. The SdrsVMAntiAffinityRule defines a Storage DRS inter-VM anti-affinity rule. It is only applicable when creating a virtual machine on a DatastoreCluster. You can create an instance of the object by invoking its constructor. The constructor has one parameter - an array of virtual machines - "public SdrsVMAntiAffinityRule(param VirtualMachine[] vm)". Then you can pass the instance to the AdvancedOption parameter of the New-VM cmdlet. ?he new virtual machine and the virtual machines specified in the constructor are placed in an inter-VM anti-affinity rule on a DatastoreCluster. |
optional | BootDelayMillisecond | Int64 | named |
|
Specifies the time interval in milliseconds between a virtual machine power on or restart and the beginning of the boot sequence. |
optional | Datastore | StorageResource | named |
|
Specifies the datastore where you want to place the new virtual machine. If a DatastoreCluster is passed to the Datastore parameter, the virtual machine is placed in the DatastoreCluster in an automated SDRS mode and with enabled intra-VM affinity rule (unless another rule is specified). You can specify a SDRS rule when creating the virtual machine in a DatastoreCluster by passing either a SdrsVMDiskAntiAffinityRule object or a SdrsVMAntiAffinityRule object to the AdvancedOption parameter. These two rules are mutually exclusive. |
optional | DiskStorageFormat | VirtualDiskStorageFormat | named |
|
Specifies the storage format of the disks of the virtual machine. This parameter accepts Thin, Thick, and EagerZeroedThick values. |
optional | DrsAutomationLevel | DrsAutomationLevel | named |
|
Specifies 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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HAIsolationResponse | HAIsolationResponse | named |
|
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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HARestartPriority | HARestartPriority | named |
|
Specifies the HA restart priority of the new virtual machine. The valid values are Disabled, Lowest, Low, Medium, High, Highest, and ClusterRestartPriority. VMware High Availability (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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | KeyProvider | KeyProvider | named |
|
Specifies the key provider that you want to use for the encryption key while creating the new virtual machine. If StoragePolicy is not specified, the default encryption storage policy "VM Encryption Policy" is used. |
optional | LinkedClone | SwitchParameter | named |
|
Indicates that you want to create a linked clone. When you set the LinkedClone parameter, the ReferenceSnapshot parameter becomes mandatory. |
optional | Location | Folder | named |
|
Specifies the folder where you want to place the new virtual machine. |
optional | Name | String | named |
|
Specifies a name for the new virtual machine. If you want to register or clone an existing virtual machine, this parameter is not mandatory. |
optional | Notes | String | named |
|
Provides a description of the new virtual machine. The alias of this parameter is Description. |
optional | OSCustomizationSpec | OSCustomizationSpec | named |
|
Specifies a customization specification that is applied to the new virtual machine. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | ReferenceSnapshot | Snapshot | named |
|
Specifies a source snapshot for the linked clone that you want to create. When you set the LinkedClone parameter, the ReferenceSnapshot parameter becomes mandatory. |
optional | ReplicationGroup | ReplicationGroup | named |
|
Specifies the ReplicationGroup where you want to place the new virtual machine. It is applicable with the storage policy provided in the StoragePolicy parameter. |
optional | ResourcePool | VIContainer | named |
|
Specifies where you want to place the new virtual machine. The parameter accepts VMHost, Cluster, ResourcePool, and VApp objects. If no value is specified, the virtual machine is added to the resource pool of its host. |
optional | RunAsync | SwitchParameter | named |
|
Indicates 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 VMware PowerCLI console. |
optional | SEVEnabled | Boolean | named |
|
Specifies whether SEV (Secure Encrypted Virtualization) is enabled or not. It allows the CPU to encrypt the memory and the state of the virtual machine. It is applicable for AMD CPUs only. |
optional | Server | VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet. |
optional | SkipHardDisks | SwitchParameter | named |
|
Specifies whether to apply the StoragePolicy or Encryption to the hard disks in the new virtual machine. |
optional | StoragePolicy | StoragePolicy | named |
|
Specifies the StoragePolicy that you want to attach to the new virtual machine during creation. If the StoragePolicy is an encryption policy, the new virtual machine is encrypted. |
optional | StoragePolicyTarget | StoragePolicyTargetType | named |
|
Specifies the target of the StoragePolicy in the virtual machine or in the VM parameter. |
optional | VApp | VApp | named |
|
This parameter is deprecated. Use the ResourcePool parameter instead. Specifies the vApp where you want to create the new virtual machine. |
optional | VMHost | VMHost | named |
|
Specifies the host on which you want to create the new virtual machine. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
Name | String | named |
|
Specifies a name for the new virtual machine. If you want to register or clone an existing virtual machine, this parameter is not mandatory. |
optional | AdvancedOption | AdvancedOption[] | named |
|
Specifies advanced options for creating virtual machines. Accepts only SdrsVMDiskAntiAffinityRule and SdrsVMAntiAffinityRule objects. The SdrsVMDiskAntiAffinityRule defines a Storage DRS intra-VM anti-affinity rule (vm disk anti-affinity rule). It is only applicable when creating a virtual machine or hard disk on a datastore cluster. You can create an instance of the object by invoking its constructor. There are two constructors - "public SdrsVMDiskAntiAffinityRule(param string[] diskIdentifier)" and "public SdrsVMDiskAntiAffinityRule(param HardDisk[] disk)". For the first constructor, "diskIdentifier" can be either the disk key or the index of the disk in the disk array. The specified disks (and the disk to which the rule is applied) are placed in an anti-affinity rule on a DatastoreCluster. Only one such rule is supported per a virtual machine. You can pass the instance to the AdvancedOption parameter of the New-VM or New-HardDisk cmdlets. The SdrsVMAntiAffinityRule defines a Storage DRS inter-VM anti-affinity rule. It is only applicable when creating a virtual machine on a DatastoreCluster. You can create an instance of the object by invoking its constructor. The constructor has one parameter - an array of virtual machines - "public SdrsVMAntiAffinityRule(param VirtualMachine[] vm)". Then you can pass the instance to the AdvancedOption parameter of the New-VM cmdlet. ?he new virtual machine and the virtual machines specified in the constructor are placed in an inter-VM anti-affinity rule on a DatastoreCluster. |
optional | AlternateGuestName | String | named |
|
Specifies the full OS name of the new virtual machine. Use this parameter if the GuestID parameter is set to otherGuest or otherGuest64. |
optional | BootDelayMillisecond | Int64 | named |
|
Specifies the time interval in milliseconds between a virtual machine power on or restart and the beginning of the boot sequence. |
optional | CD | SwitchParameter | named |
|
Indicates that you want to add a CD drive to the new virtual machine. |
optional | CoresPerSocket | Int32 | named |
|
Specifies the number of virtual CPU cores per socket. |
optional | CpuHotAddEnabled | Boolean | named |
|
Specifies if virtual processors can be added to the virtual machine while it is running. |
optional | CpuHotRemoveEnabled | Boolean | named |
|
Specifies if virtual processors can be removed from the virtual machine while it is running. |
optional | Datastore | StorageResource | named |
|
Specifies the datastore where you want to place the new virtual machine. If a DatastoreCluster is passed to the Datastore parameter, the virtual machine is placed in the DatastoreCluster in an automated SDRS mode and with enabled intra-VM affinity rule (unless another rule is specified). You can specify a SDRS rule when creating the virtual machine in a DatastoreCluster by passing either a SdrsVMDiskAntiAffinityRule object or a SdrsVMAntiAffinityRule object to the AdvancedOption parameter. These two rules are mutually exclusive. |
optional | DiskGB | Decimal[] | named |
|
Specifies the size in gigabytes (GB) of the disks that you want to create and add to the new virtual machine. |
optional | DiskMB | Int64[] | named |
|
This parameter is obsolete. Use DiskGB instead. Specifies the size in megabytes (MB) of the disks that you want to create and add to the new virtual machine. |
optional | DiskPath | String[] | named |
|
Specifies paths to virtual disks that you want to add to the new virtual machine. |
optional | DiskStorageFormat | VirtualDiskStorageFormat | named |
|
Specifies the storage format of the disks of the virtual machine. This parameter accepts Thin, Thick, and EagerZeroedThick values. |
optional | DrsAutomationLevel | DrsAutomationLevel | named |
|
Specifies 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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | Floppy | SwitchParameter | named |
|
Indicates that you want to add a floppy drive to the new virtual machine. |
optional | GuestId | String | named |
|
Specifies 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. |
optional | HAIsolationResponse | HAIsolationResponse | named |
|
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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HARestartPriority | HARestartPriority | named |
|
Specifies the HA restart priority of the new virtual machine. The valid values are Disabled, Lowest, Low, Medium, High, Highest, and ClusterRestartPriority. VMware High Availability (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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HardwareVersion | String | named |
|
Specifies the version of the new virtual machine. By default, the new virtual machine is created with the latest available version. |
optional | KeyProvider | KeyProvider | named |
|
Specifies the key provider that you want to use for the encryption key while creating the new virtual machine. If StoragePolicy is not specified, the default encryption storage policy "VM Encryption Policy" is used. |
optional | Location | Folder | named |
|
Specifies the folder where you want to place the new virtual machine. |
optional | MemoryGB | Decimal | named |
|
Specifies the memory size in gigabytes (GB) of the new virtual machine. |
optional | MemoryHotAddEnabled | Boolean | named |
|
Specifies if memory can be added to the virtual machine while it is running. |
optional | MemoryMB | Int64 | named |
|
This parameter is obsolete. Use MemoryGB instead. Specifies the memory size in megabytes (MB) of the new virtual machine. |
optional | MigrationEncryption | VMMigrationEncryptionMode | named |
|
Specifies the encryption behavior when migrating the virtual machine. Valid options are: - Disabled: Do not use encrypted vSphere vMotion. - Opportunistic: Use encrypted vSphere vMotion if source and destination hosts support it. Only ESXi versions 6.5 and later use encrypted vSphere vMotion. - Required: Allow only encrypted vSphere vMotion. If the source or destination host does not support encrypted vSphere vMotion, migration with vSphere vMotion is not allowed. |
optional | NetworkName | String[] | named |
|
Specifies the networks to which you want to connect the new virtual machine. Specifying a distributed port group name is obsolete. Use the Portgroup parameter instead. |
optional | Notes | String | named |
|
Provides a description of the new virtual machine. The alias of this parameter is Description. |
optional | NumCpu | Int32 | named |
|
Specifies the number of the virtual CPUs of the new virtual machine. |
optional | Portgroup | VirtualPortGroupBase[] | named |
|
Specifies standard or distributed port groups to which you want to connect the virtual machine. For each specified port group, a new network adapter is created. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | ReplicationGroup | ReplicationGroup | named |
|
Specifies the ReplicationGroup where you want to place the new virtual machine. It is applicable with the storage policy provided in the StoragePolicy parameter. |
optional | ResourcePool | VIContainer | named |
|
Specifies where you want to place the new virtual machine. The parameter accepts VMHost, Cluster, ResourcePool, and VApp objects. If no value is specified, the virtual machine is added to the resource pool of its host. |
optional | RunAsync | SwitchParameter | named |
|
Indicates 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 VMware PowerCLI console. |
optional | SEVEnabled | Boolean | named |
|
Specifies whether SEV (Secure Encrypted Virtualization) is enabled or not. It allows the CPU to encrypt the memory and the state of the virtual machine. It is applicable for AMD CPUs only. |
optional | Server | VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet. |
optional | SkipHardDisks | SwitchParameter | named |
|
Specifies whether to apply the StoragePolicy or Encryption to the hard disks in the new virtual machine. |
optional | StoragePolicy | StoragePolicy | named |
|
Specifies the StoragePolicy that you want to attach to the new virtual machine during creation. If the StoragePolicy is an encryption policy, the new virtual machine is encrypted. |
optional | VApp | VApp | named |
|
This parameter is deprecated. Use the ResourcePool parameter instead. Specifies the vApp where you want to create the new virtual machine. |
optional | VMHost | VMHost | named |
|
Specifies the host on which you want to create the new virtual machine. |
optional | VMSwapfilePolicy | VMSwapfilePolicy | named |
|
Specifies the swapfile placement policy. The following values are valid: InHostDataStore - stores 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 - stores the swapfile in the same directory as the virtual machine. |
optional | Version | VMVersion | named |
|
This parameter is deprecated. Use the HardwareVersion parameter instead. Specifies the version of the new virtual machine. The valid values are v4, v7, v8, v9, v10, v11, v12, v13, and v14. By default, the new virtual machine is created with the latest available version. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
ContentLibraryItem | ContentLibraryItem | 1 |
|
Specifies the content library template from which you want to deploy the virtual machine. |
optional | CoresPerSocket | Int32 | named |
|
Specifies the number of virtual CPU cores per socket. |
optional | Datastore | StorageResource | named |
|
Specifies the datastore where you want to place the new virtual machine. If a DatastoreCluster is passed to the Datastore parameter, the virtual machine is placed in the DatastoreCluster in an automated SDRS mode and with enabled intra-VM affinity rule (unless another rule is specified). You can specify a SDRS rule when creating the virtual machine in a DatastoreCluster by passing either a SdrsVMDiskAntiAffinityRule object or a SdrsVMAntiAffinityRule object to the AdvancedOption parameter. These two rules are mutually exclusive. |
optional | DiskGB | Decimal[] | named |
|
Specifies the size in gigabytes (GB) of the disks that you want to create and add to the new virtual machine. |
optional | DiskMB | Int64[] | named |
|
This parameter is obsolete. Use DiskGB instead. Specifies the size in megabytes (MB) of the disks that you want to create and add to the new virtual machine. |
optional | DiskStorageFormat | VirtualDiskStorageFormat | named |
|
Specifies the storage format of the disks of the virtual machine. This parameter accepts Thin, Thick, and EagerZeroedThick values. |
optional | DrsAutomationLevel | DrsAutomationLevel | named |
|
Specifies 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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HAIsolationResponse | HAIsolationResponse | named |
|
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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HARestartPriority | HARestartPriority | named |
|
Specifies the HA restart priority of the new virtual machine. The valid values are Disabled, Lowest, Low, Medium, High, Highest, and ClusterRestartPriority. VMware High Availability (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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | Location | Folder | named |
|
Specifies the folder where you want to place the new virtual machine. |
optional | MemoryGB | Decimal | named |
|
Specifies the memory size in gigabytes (GB) of the new virtual machine. |
optional | MemoryMB | Int64 | named |
|
This parameter is obsolete. Use MemoryGB instead. Specifies the memory size in megabytes (MB) of the new virtual machine. |
optional | Name | String | named |
|
Specifies a name for the new virtual machine. If you want to register or clone an existing virtual machine, this parameter is not mandatory. |
optional | NetworkName | String[] | named |
|
Specifies the networks to which you want to connect the new virtual machine. Specifying a distributed port group name is obsolete. Use the Portgroup parameter instead. |
optional | Notes | String | named |
|
Provides a description of the new virtual machine. The alias of this parameter is Description. |
optional | NumCpu | Int32 | named |
|
Specifies the number of the virtual CPUs of the new virtual machine. |
optional | OSCustomizationSpec | OSCustomizationSpec | named |
|
Specifies a customization specification that is applied to the new virtual machine. |
optional | OvfConfiguration | Hashtable | named |
|
Specifies values for a set of user-configurable OVF properties. |
optional | Portgroup | VirtualPortGroupBase[] | named |
|
Specifies standard or distributed port groups to which you want to connect the virtual machine. For each specified port group, a new network adapter is created. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | ResourcePool | VIContainer | named |
|
Specifies where you want to place the new virtual machine. The parameter accepts VMHost, Cluster, ResourcePool, and VApp objects. If no value is specified, the virtual machine is added to the resource pool of its host. |
optional | RunAsync | SwitchParameter | named |
|
Indicates 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 VMware PowerCLI console. |
optional | Server | VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet. |
optional | StoragePolicy | StoragePolicy | named |
|
Specifies the StoragePolicy that you want to attach to the new virtual machine during creation. If the StoragePolicy is an encryption policy, the new virtual machine is encrypted. |
optional | VMHost | VMHost | named |
|
Specifies the host on which you want to create the new virtual machine. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
VMFilePath | String | named |
|
Specifies a path to the virtual machine that you want to register. |
optional | BootDelayMillisecond | Int64 | named |
|
Specifies the time interval in milliseconds between a virtual machine power on or restart and the beginning of the boot sequence. |
optional | DrsAutomationLevel | DrsAutomationLevel | named |
|
Specifies 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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HAIsolationResponse | HAIsolationResponse | named |
|
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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HARestartPriority | HARestartPriority | named |
|
Specifies the HA restart priority of the new virtual machine. The valid values are Disabled, Lowest, Low, Medium, High, Highest, and ClusterRestartPriority. VMware High Availability (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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | Location | Folder | named |
|
Specifies the folder where you want to place the new virtual machine. |
optional | Name | String | named |
|
Specifies a name for the new virtual machine. If you want to register or clone an existing virtual machine, this parameter is not mandatory. |
optional | Notes | String | named |
|
Provides a description of the new virtual machine. The alias of this parameter is Description. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | ResourcePool | VIContainer | named |
|
Specifies where you want to place the new virtual machine. The parameter accepts VMHost, Cluster, ResourcePool, and VApp objects. If no value is specified, the virtual machine is added to the resource pool of its host. |
optional | RunAsync | SwitchParameter | named |
|
Indicates 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 VMware PowerCLI console. |
optional | SEVEnabled | Boolean | named |
|
Specifies whether SEV (Secure Encrypted Virtualization) is enabled or not. It allows the CPU to encrypt the memory and the state of the virtual machine. It is applicable for AMD CPUs only. |
optional | Server | VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet. |
optional | VApp | VApp | named |
|
This parameter is deprecated. Use the ResourcePool parameter instead. Specifies the vApp where you want to create the new virtual machine. |
optional | VMHost | VMHost | named |
|
Specifies the host on which you want to create the new virtual machine. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
Template | Template | 1 |
|
Specifies the virtual machine template that 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 deactivated in a future release. |
required
|
Name | String | named |
|
Specifies a name for the new virtual machine. If you want to register or clone an existing virtual machine, this parameter is not mandatory. |
optional | AdvancedOption | AdvancedOption[] | named |
|
Specifies advanced options for creating virtual machines. Accepts only SdrsVMDiskAntiAffinityRule and SdrsVMAntiAffinityRule objects. The SdrsVMDiskAntiAffinityRule defines a Storage DRS intra-VM anti-affinity rule (vm disk anti-affinity rule). It is only applicable when creating a virtual machine or hard disk on a datastore cluster. You can create an instance of the object by invoking its constructor. There are two constructors - "public SdrsVMDiskAntiAffinityRule(param string[] diskIdentifier)" and "public SdrsVMDiskAntiAffinityRule(param HardDisk[] disk)". For the first constructor, "diskIdentifier" can be either the disk key or the index of the disk in the disk array. The specified disks (and the disk to which the rule is applied) are placed in an anti-affinity rule on a DatastoreCluster. Only one such rule is supported per a virtual machine. You can pass the instance to the AdvancedOption parameter of the New-VM or New-HardDisk cmdlets. The SdrsVMAntiAffinityRule defines a Storage DRS inter-VM anti-affinity rule. It is only applicable when creating a virtual machine on a DatastoreCluster. You can create an instance of the object by invoking its constructor. The constructor has one parameter - an array of virtual machines - "public SdrsVMAntiAffinityRule(param VirtualMachine[] vm)". Then you can pass the instance to the AdvancedOption parameter of the New-VM cmdlet. ?he new virtual machine and the virtual machines specified in the constructor are placed in an inter-VM anti-affinity rule on a DatastoreCluster. |
optional | BootDelayMillisecond | Int64 | named |
|
Specifies the time interval in milliseconds between a virtual machine power on or restart and the beginning of the boot sequence. |
optional | Datastore | StorageResource | named |
|
Specifies the datastore where you want to place the new virtual machine. If a DatastoreCluster is passed to the Datastore parameter, the virtual machine is placed in the DatastoreCluster in an automated SDRS mode and with enabled intra-VM affinity rule (unless another rule is specified). You can specify a SDRS rule when creating the virtual machine in a DatastoreCluster by passing either a SdrsVMDiskAntiAffinityRule object or a SdrsVMAntiAffinityRule object to the AdvancedOption parameter. These two rules are mutually exclusive. |
optional | DiskStorageFormat | VirtualDiskStorageFormat | named |
|
Specifies the storage format of the disks of the virtual machine. This parameter accepts Thin, Thick, and EagerZeroedThick values. |
optional | DrsAutomationLevel | DrsAutomationLevel | named |
|
Specifies 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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HAIsolationResponse | HAIsolationResponse | named |
|
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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | HARestartPriority | HARestartPriority | named |
|
Specifies the HA restart priority of the new virtual machine. The valid values are Disabled, Lowest, Low, Medium, High, Highest, and ClusterRestartPriority. VMware High Availability (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 deactivated in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears. |
optional | KeyProvider | KeyProvider | named |
|
Specifies the key provider that you want to use for the encryption key while creating the new virtual machine. If StoragePolicy is not specified, the default encryption storage policy "VM Encryption Policy" is used. |
optional | Location | Folder | named |
|
Specifies the folder where you want to place the new virtual machine. |
optional | NetworkName | String[] | named |
|
Specifies the networks to which you want to connect the new virtual machine. Specifying a distributed port group name is obsolete. Use the Portgroup parameter instead. |
optional | Notes | String | named |
|
Provides a description of the new virtual machine. The alias of this parameter is Description. |
optional | OSCustomizationSpec | OSCustomizationSpec | named |
|
Specifies a customization specification that is applied to the new virtual machine. |
optional | Portgroup | VirtualPortGroupBase[] | named |
|
Specifies standard or distributed port groups to which you want to connect the virtual machine. For each specified port group, a new network adapter is created. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | ReplicationGroup | ReplicationGroup | named |
|
Specifies the ReplicationGroup where you want to place the new virtual machine. It is applicable with the storage policy provided in the StoragePolicy parameter. |
optional | ResourcePool | VIContainer | named |
|
Specifies where you want to place the new virtual machine. The parameter accepts VMHost, Cluster, ResourcePool, and VApp objects. If no value is specified, the virtual machine is added to the resource pool of its host. |
optional | RunAsync | SwitchParameter | named |
|
Indicates 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 VMware PowerCLI console. |
optional | SEVEnabled | Boolean | named |
|
Specifies whether SEV (Secure Encrypted Virtualization) is enabled or not. It allows the CPU to encrypt the memory and the state of the virtual machine. It is applicable for AMD CPUs only. |
optional | Server | VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of the Connect-VIServer cmdlet. |
optional | SkipHardDisks | SwitchParameter | named |
|
Specifies whether to apply the StoragePolicy or Encryption to the hard disks in the new virtual machine. |
optional | StoragePolicy | StoragePolicy | named |
|
Specifies the StoragePolicy that you want to attach to the new virtual machine during creation. If the StoragePolicy is an encryption policy, the new virtual machine is encrypted. |
optional | StoragePolicyTarget | StoragePolicyTargetType | named |
|
Specifies the target of the StoragePolicy in the virtual machine or in the VM parameter. |
optional | VApp | VApp | named |
|
This parameter is deprecated. Use the ResourcePool parameter instead. Specifies the vApp where you want to create the new virtual machine. |
optional | VMHost | VMHost | named |
|
Specifies the host on which you want to create the new virtual machine. |
Output
VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachineExamples
Example 1
$myTargetVMHost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM1 -ResourcePool $myTargetVMHost -Datastore MyDatastore1 -NumCPU 2 -MemoryGB 4 -DiskGB 40 -NetworkName "VM Network" -Floppy -CD -DiskStorageFormat Thin -GuestID winNetDatacenterGuest
Creates a virtual machine by specifying a target host, a target datastore, and a network to connect to, and configures the settings for the virtual machine.
Example 2
$myCluster = Get-Cluster -Name MyCluster1 New-VM -Name MyVM1 -ResourcePool $myCluster
Creates a virtual machine by specifying a cluster. The ResourcePool parameter accepts ResourcePool, Cluster, VApp, and standalone VMHost objects.
Example 3
$vmhost = Get-VMHost -Name MyVMHost1 $myCluster = Get-Cluster -Name MyCluster1 New-VM -Name MyVM1 -VMHost $vmhost -ResourcePool $myCluster -DiskGB 4 -MemoryGB 1
Creates a virtual machine by specifying a cluster and explicitly selecting the host, instead of allowing autoselection of a target host.
Example 4
$vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM1 -ResourePool $vmhost -DiskGB 40,100
Creates a virtual machine with multiple disks.
Example 5
$vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM1 -ResourcePool $vmhost -DiskPath "[Storage1] WindowsXP/WindowsXP.vmdk"
Creates a virtual machine by specifying an existing disk.
Example 6
$vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM1 -ResourcePool $vmhost -HardwareVersion vmx-04
Creates a virtual machine by explicitly specifying the version of the virtual machine hardware through the HardwareVersion parameter.
Example 7
$keyprovider = Get-KeyProvider "MyKeyProvider" $ds = Get-Datastore -VMHost MyHost1 New-VM -Name 'MyVM' -VMHost MyHost1 -Datastore $ds -KeyProvider $keyprovider
Creates an encrypted virtual machine on the given $ds datastore and MyHost1 host.
Example 8
$policy = Get-SpbmStoragePolicy "MyPolicy" $ds = Get-Datastore -VMHost MyHost1 New-VM -Name 'MyVM' -VMHost MyHost1 -Datastore $ds -StoragePolicy $policy -SkipHardDisks
Creates a virtual machine with the $policy storage policy attached to its VM Home on the given $ds datastore and MyHost1 host. If the $policy is an encryption policy, VM Home of the virtual machine is encrypted during creation.
Example 9
$myDatastore = Get-Datastore -Name MyDatastore1 $vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM2 -VM MyVM1 -Datastore $myDatastore -VMHost $vmhost
Creates a new virtual machine named MyVM2 by cloning the MyVM1 virtual machine on the specified datastore and host.
Example 10
New-VM -VM MyVM1, MyVM2 -Location MyFolder1 -VMHost MyHost1
Copies the MyVM1 and MyVM2 virtual machines to the MyFolder1 folder on the MyHost1 host.
Example 11
$myResourcePool = Get-ResourcePool -Name MyResourcePool1 $mySpecification = Get-OSCustomizationSpec -Name WindowsSpec New-VM -VM MyVM1 -Name MyVM2 -OSCustomizationSpec $mySpecification -ResourcePool $myResourcePool
Clones the virtual machine MyVM1 to MyVM2 and applies a customization specification on the cloned virtual machine.
Example 12
$myResourcePool = Get-ResourcePool -Name MyResourcePool1 $myTemplate = Get-Template -Name WindowsTemplate $mySpecification = Get-OSCustomizationSpec -Name WindowsSpec New-VM -Name MyVM2 -Template $myTemplate -ResourcePool $myResourcePool -OSCustomizationSpec $mySpecification
Creates a virtual machine from the specified template and applies the specified customization specification.
Example 13
cd vmstores:\myserver@443\Datacenter\Storage1\MyVM1\ $vmxFile = Get-Item MyVM1.vmx $vmhost = Get-VMHost -Name MyVMHost1 New-VM -VMHost $vmhost -VMFilePath $vmxFile.DatastoreFullPath
Retrieves the specified configuration file for the MyVM1 virtual machine and registers the MyVM1 virtual machine on the specified host.
Example 14
$vmhost = Get-VMHost -Name MyVMHost1 $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster1 New-VM -Name MyVM1 -DiskGB 40,40 -Datastore $myDatastoreCluster -ResourcePool $vmhost
Creates a virtual machine on a datastore cluster. By default, the new virtual machine has an intra-VM affinity rule.
Example 15
$vmhost = Get-VMHost -Name MyVMHost1 $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster1 $myAdvancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMDiskAntiAffinityRule' 1,2 New-VM -Name MyVM1 -DiskGB 40,40,40 -Datastore $myDatastoreCluster -AdvancedOption $myAdvancedOption -ResourcePool $vmhost
Creates a virtual machine on a datastore cluster. The machine has three hard disks. For the first two disks, the intra-VM anti-affinity rule is specified and the disks are placed on a datastore different from the datastore cluster. Identifying the hard disk in the intra-VM anti-affinity happens by indexing the disks starting from 1.
Example 16
$myVM1 = Get-VM -Name WindowsXP $myResourcePool = Get-ResourcePool -Name MyResourcePool1 $myAdvancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMAntiAffinityRule' $myVM1 $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster1 New-VM -Name MyVM1 -DiskGB 40,40,40 -Datastore $myDatastoreCluster -AdvancedOption $myAdvancedOption -ResourcePool $myResourcePool
Creates a virtual machine on a datastore cluster and specifies a VM anti-affinity rule between the new virtual machine and an existing virtual machine.
Example 17
$mySourceVM = Get-VM -Name MySourceVM1 $vmhost = Get-VMHost -Name MyVMHost1 $hardDiskList = Get-HardDisk -VM $vm | select -First 2 $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster1 $myAdvancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMDiskAntiAffinityRule' $hardDiskList New-VM -Name MyVM1 -VM $mySourceVM -Datastore $myDatastoreCluster -AdvancedOption $myAdvancedOption -ResourcePool $vmhost
Clones a virtual machine on a datastore cluster and specifies an intra-VM anti-affinity rule by using references to the hard disks of the source virtual machine. When you apply this rule to the AdvancedOption parameter of the New-VM cmdlet, the first disk and the second disk of the new virtual machine are placed on different datastores within the specified datastore cluster.
Example 18
$mySourceVM = Get-VM -Name MySourceVM1 $myVM1 = Get-VM -Name WindowsXP $myAdvancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMAntiAffinityRule' $myVM1 $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster1 $vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM2 -VM $mySourceVM -Datastore $myDatastoreCluster -AdvancedOption $myAdvancedOption -ResourcePool $vmhost
Clones a virtual machine on a datastore cluster and specifies a VM anti-afffinity rule between the new virtual machine and an existing virtual machine. When you apply this rule to the AdvancedOption parameter of the New-VM cmdlet, the new virtual machine and the WindowsXP virtual machine are placed on different datastores within the specified datastore cluster.
Example 19
$mySourceTemplate = Get-Template -Name WindowsTemplate $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster $myAdvancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMDiskAntiAffinityRule' $hardDiskList $vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM1 -Template $mySourceTemplate -Datastore $myDatastoreCluster -AdvancedOption $myAdvancedOption -ResourcePool $vmhost
Creates a virtual machine from a template, specifies a VM anti-affinity rule, and stores the virtual machine on a specified datastore cluster.
Example 20
$vmhost = Get-VMHost -Name MyVMHost1 $myVM = Get-VM -Name WindowsXP $mySourceTemplate = Get-Template -Name WindowsTemplate $myDatastoreCluster = Get-DatastoreCluster -Name MyStorageCluster1 $myAdvancedOption = New-Object 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.SdrsVMAntiAffinityRule' $myVM New-VM -Name VM -Template $mySourceTemplate -Datastore $myDatastoreCluster -AdvancedOption $myAdvancedOption -ResourcePool $vmhost
Creates a virtual machine from a template, specifies a VM anti-affinity rule, and stores the virtual machine on a specified datastore cluster.
Example 21
$mySourceVM = Get-VM -Name MySourceVM1 $myReferenceSnapshot = Get-Snapshot -VM $mySourceVM -Name "InitialState" $vmhost = Get-VMHost -Name MyVMHost1 $myDatastore = Get-Datastore -Name MyDatastore1 New-VM -Name MyLinkedCloneVM1 -VM $mySourceVM -LinkedClone -ReferenceSnapshot $myReferenceSnapshot -ResourcePool $vmhost -Datastore $myDatastore
Creates a linked clone from the specified snapshot of the parent virtual machine. The linked clone is stored on the specified VM host and datastore.
Example 22
$myCluster = Get-Cluster -Name "MyCluster" $myVDPortGroup = Get-VDPortgroup -Name "MyVDPortGroup" $mySharedDatastore = Get-Datastore -Name "MySharedDatastore" New-VM -Name MyVM -ResourcePool $myCluster -Portgroup $myVDPortGroup -DiskGB 40 -MemoryGB 4 -Datastore $mySharedDatastore
Creates a new virtual machine with the specified configuration and connects it to the specified distributed port group.
Example 23
$vmhost = Get-VMHost -Name MyVMHost1 New-VM -Name MyVM1 -VMHost $vmhost -SEVEnabled $true
Creates a new virtual machine and enables SEV (Secure Encrypted Virtualization) for the virtual machine.
Example 24
$datastore = Get-Datastore -Name 'MyDatastore' $portGroup = Get-VirtualPortGroup -Name "VM Network" -Standard $contentLibraryItem = Get-ContentLibraryItem -Name 'MyContentLibraryItem' $target = Get-VMHost -Name 'MyVMHost' $ovfConfig = Get-OvfConfiguration -ContentLibraryItem $contentLibraryItem -Target $target $ovfConfig.EULAs.Accept.Value = $true $ovfConfig.NetworkMapping.Network.Value = $portGroup New-VM -Name 'MyVM1' -VMHost $target -Datastore $datastore -ContentLibraryItem $contentLibraryItem -OvfConfiguration $ovfConfig
Deploys a virtual machine named MyVM1 from a content library item by specifying network mapping with a standard port group object and accepting all EULAs.
Example 25
$vmhost = Get-VMHost -Name 'MyVMHost' $contentLibraryItem = Get-ContentLibraryItem -Name 'MyContentLibraryItem' $datastore = Get-Datastore -Name 'MyDatastore' $vdPortGroup = Get-VDPortgroup -Name 'MyVDPortGroup'' New-VM -Name 'MyVM1' -VMHost $vmhost -ContentLibraryItem $contentLibraryItem -Datastore $datastore -NumCpu 1 -MemoryGB 1 -DiskGB 4 -Portgroup $vdPortGroup
Deploys a virtual machine named 'MyVM1' from a virtual machine template content library item with the specified configuration and connects the virtual machine to the specified distributed port group.
Example 26
$vmhost = Get-VMHost -Name 'MyVMHost' $datastore = Get-Datastore -Name 'MyDatastore' New-VM -Name 'MyVM1' -VMHost $vmhost -Datastore $datastore -MemoryGB 1 -DiskGB 4 -BootDelayMillisecond 5000
Creates a virtual machine named 'MyVM1' and sets the boot delay between the virtual machine power on or restart and the beginning of the boot sequence to 5000 milliseconds.
Related Commands
VM
This cmdlet retrieves the virtual machines on a vCenter Server system.
This cmdlet moves virtual machines to another location.
This cmdlet creates a new virtual machine.
This cmdlet removes the specified virtual machines from the vCenter Server system.
This cmdlet restarts the specified virtual machines.
This cmdlet modifies the configuration of the virtual machine.
This cmdlet powers on virtual machines.
This cmdlet powers off virtual machines.
This cmdlet suspends virtual machines.
This cmdlet unlocks the specified virtual machine.
VMConsoleWindow
This cmdlet opens a window to the virtual machine's console.
VMGuest
This cmdlet retrieves the guest operating systems of the specified virtual machines.
This cmdlet restarts the virtual machine guest operating systems.
This cmdlet shuts down the specified virtual machine guest OS.
This cmdlet suspends the specified guest operating systems.
VMGuestDisk
This cmdlet retrieves storage volumes as seen by the virtual machines' guest operating systems.
VMGuestFile
This cmdlet copies files and folders from and to the guest OS of the specified virtual machines using VMware Tools.
VMQuestion
This cmdlet retrieves the pending questions for the specified virtual machines.
This cmdlet answers the specified virtual machine question.
VMResourceConfiguration
This cmdlet retrieves information about the resource allocation between the selected virtual machines.
This cmdlet configures resource allocation between the virtual machines.
VMScript
This cmdlet runs a script in the guest OS of each of the specified virtual machines.
VMStartPolicy
This cmdlet retrieves the start policy of the virtual machines on a vCenter Server system.
This cmdlet modifies the virtual machine start policy.