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

-Name  <String>
[-AdvancedOption  <AdvancedOption[]>]
[-AlternateGuestName  <String>]
[-CD]
[-CoresPerSocket  <Int32>]
[-Datastore  <StorageResource>]
[-DiskGB  <Decimal[]>]
[-DiskMB  <Int64[]>]
[-DiskPath  <String[]>]
[-DiskStorageFormat  <VirtualDiskStorageFormat>]
[-DrsAutomationLevel  <DrsAutomationLevel>]
[-Floppy]
[-GuestId  <String>]
[-HAIsolationResponse  <HAIsolationResponse>]
[-HARestartPriority  <HARestartPriority>]
[-HardwareVersion  <String>]
[-KeyProvider  <KmsCluster>]
[-Location  <Folder>]
[-MemoryGB  <Decimal>]
[-MemoryMB  <Int64>]
[-NetworkName  <String[]>]
[-Notes  <String>]
[-NumCpu  <Int32>]
[-Portgroup  <VirtualPortGroupBase[]>]
[-ReplicationGroup  <ReplicationGroup>]
[-ResourcePool  <VIContainer>]
[-RunAsync]
[-SEVEnabled  <Boolean>]
[-Server  <VIServer[]>]
[-SkipHardDisks]
[-StoragePolicy  <StoragePolicy>]
[-VApp  <VApp>]
[-VMHost  <VMHost>]
[-VMSwapfilePolicy  <VMSwapfilePolicy>]
[-Version  <VMVersion>]
[CommonParameters]

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.
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
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
Datastore
StorageResource named
  • wildcards
  • 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 disabled 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 disabled 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, Low, Medium, High, 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 disabled 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
    KmsCluster 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
  • wildcards
  • 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
    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
    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
  • wildcards
  • pipeline
  • 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
  • wildcards
  • 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
  • wildcards
  • pipeline
  • 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
  • wildcards
  • pipeline
  • 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:
    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.

    -VM  <VirtualMachine[]>
    [-AdvancedOption  <AdvancedOption[]>]
    [-Datastore  <StorageResource>]
    [-DiskStorageFormat  <VirtualDiskStorageFormat>]
    [-DrsAutomationLevel  <DrsAutomationLevel>]
    [-HAIsolationResponse  <HAIsolationResponse>]
    [-HARestartPriority  <HARestartPriority>]
    [-LinkedClone]
    [-Location  <Folder>]
    [-Name  <String>]
    [-Notes  <String>]
    [-OSCustomizationSpec  <OSCustomizationSpec>]
    [-ReferenceSnapshot  <Snapshot>]
    [-ReplicationGroup  <ReplicationGroup>]
    [-ResourcePool  <VIContainer>]
    [-RunAsync]
    [-SEVEnabled  <Boolean>]
    [-Server  <VIServer[]>]
    [-StoragePolicy  <StoragePolicy>]
    [-StoragePolicyTarget  <StoragePolicyTargetType>]
    [-VApp  <VApp>]
    [-VMHost  <VMHost>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    VM
    VirtualMachine[] named
  • wildcards
  • pipeline
  • 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.
    optional
    Datastore
    StorageResource named
  • wildcards
  • 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 disabled 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 disabled 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, Low, Medium, High, 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 disabled in a future release. Specifying this parameter is only supported when the virtual machine is inside a cluster. Otherwise, an error appears.
    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
  • wildcards
  • 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
    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
  • wildcards
  • pipeline
  • 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
  • wildcards
  • 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
    StoragePolicyTarget
    StoragePolicyTargetType named Specifies the target of the StoragePolicy in the virtual machine or in the VM parameter.
    optional
    VApp
    VApp named
  • wildcards
  • pipeline
  • 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
  • wildcards
  • pipeline
  • Specifies the host on which you want to create the new virtual machine.

    [-ContentLibraryItem]  <ContentLibraryItem>
    [-Datastore  <StorageResource>]
    [-DiskStorageFormat  <VirtualDiskStorageFormat>]
    [-DrsAutomationLevel  <DrsAutomationLevel>]
    [-HAIsolationResponse  <HAIsolationResponse>]
    [-HARestartPriority  <HARestartPriority>]
    [-Location  <Folder>]
    [-Name  <String>]
    [-ResourcePool  <VIContainer>]
    [-RunAsync]
    [-Server  <VIServer[]>]
    [-VMHost  <VMHost>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    ContentLibraryItem
    ContentLibraryItem 1
  • pipeline
  • Specifies the content library template from which you want to deploy the virtual machine.
    optional
    Datastore
    StorageResource named
  • wildcards
  • 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 disabled 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 disabled 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, Low, Medium, High, 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 disabled 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
  • wildcards
  • 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
    ResourcePool
    VIContainer named
  • wildcards
  • pipeline
  • 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
  • wildcards
  • 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
    VMHost
    VMHost named
  • wildcards
  • pipeline
  • Specifies the host on which you want to create the new virtual machine.

    -VMFilePath  <String>
    [-DrsAutomationLevel  <DrsAutomationLevel>]
    [-HAIsolationResponse  <HAIsolationResponse>]
    [-HARestartPriority  <HARestartPriority>]
    [-Location  <Folder>]
    [-Name  <String>]
    [-Notes  <String>]
    [-ResourcePool  <VIContainer>]
    [-RunAsync]
    [-SEVEnabled  <Boolean>]
    [-Server  <VIServer[]>]
    [-VApp  <VApp>]
    [-VMHost  <VMHost>]
    [CommonParameters]

    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
    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 disabled 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 disabled 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, Low, Medium, High, 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 disabled 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
  • wildcards
  • 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
    ResourcePool
    VIContainer named
  • wildcards
  • pipeline
  • 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
  • wildcards
  • 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
  • wildcards
  • pipeline
  • 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
  • wildcards
  • pipeline
  • Specifies the host on which you want to create the new virtual machine.

    [-Template]  <Template>
    -Name  <String>
    [-AdvancedOption  <AdvancedOption[]>]
    [-Datastore  <StorageResource>]
    [-DiskStorageFormat  <VirtualDiskStorageFormat>]
    [-DrsAutomationLevel  <DrsAutomationLevel>]
    [-HAIsolationResponse  <HAIsolationResponse>]
    [-HARestartPriority  <HARestartPriority>]
    [-Location  <Folder>]
    [-NetworkName  <String[]>]
    [-Notes  <String>]
    [-OSCustomizationSpec  <OSCustomizationSpec>]
    [-Portgroup  <VirtualPortGroupBase[]>]
    [-ReplicationGroup  <ReplicationGroup>]
    [-ResourcePool  <VIContainer>]
    [-RunAsync]
    [-SEVEnabled  <Boolean>]
    [-Server  <VIServer[]>]
    [-StoragePolicy  <StoragePolicy>]
    [-StoragePolicyTarget  <StoragePolicyTargetType>]
    [-VApp  <VApp>]
    [-VMHost  <VMHost>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    Template
    Template 1
  • wildcards
  • pipeline
  • 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 disabled 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.
    optional
    Datastore
    StorageResource named
  • wildcards
  • 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 disabled 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 disabled 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, Low, Medium, High, 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 disabled 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
  • wildcards
  • 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
    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
  • wildcards
  • pipeline
  • 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
  • wildcards
  • 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
    StoragePolicyTarget
    StoragePolicyTargetType named Specifies the target of the StoragePolicy in the virtual machine or in the VM parameter.
    optional
    VApp
    VApp named
  • wildcards
  • pipeline
  • 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
  • wildcards
  • pipeline
  • Specifies the host on which you want to create the new virtual machine.

    Output

    VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine

    Examples


    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.

    Related Commands

    Feedback

    Was this page helpful?