VMware Cloud Community
andvm
Hot Shot
Hot Shot

New-VM using powercli

Hi,

    $myCluster = Get-Cluster -Name "MyCluster"

    $myVDPortGroup = Get-VDPortgroup -Name "DPortGroup-Default"

    $mySharedDatastore = Get-Datastore -Name "vsanDatastore"

    New-VM -Name powercliVM03 -ResourcePool $myCluster -Portgroup $myVDPortGroup -DiskGB 1 -MemoryGB 1 -Datastore $mySharedDatastore

say I have 5 hosts in the cluster with DRS disabled, how is the decision made as in which host will the VM be created on?

Can I specify a host directly within the cluster?

Thanks

3 Replies
SupreetK
Commander
Commander

Use the switch <-VMHost> to specify the host on which the VM should be created -

New-VM -VMHost hostname -Name powercliVM03 .....

Please consider marking this answer as "correct" or "helpful" if you think your questions have been answered.

Cheers,

Supreet

andvm
Hot Shot
Hot Shot

ok, will I still need to specify the cluster?

Do I need to specify other parameters to ensure its disk is protected by the "vSAN Default Storage Policy" as even though the datastore is set "vsanDatastore" in the command, am noticing that the disk is created as a Thick provision lazy zeroed.

Thanks

0 Kudos
SupreetK
Commander
Commander

Per my understanding, we need to assign the storage policy to the VM. Please refer to step-8 in the below link -

VMware vSphere 6.5 Documentation Library

Cheers,

Supreet

0 Kudos