VMware Cloud Community
chakoe
Enthusiast
Enthusiast

New-VM cmdlet creates VM´s with VM-Version4

Hi,

the following (part of my) script creates VM´s with the VM-Version 4:

New-VM -Host $Horst -Name $vmName -DiskMB $HDsize -MemoryMB $RAMsize -NumCPU $ProcNum -GuestID $OSname -Datastore $Datastore -NetworkName $Network -CD -Description $Description

How do i create VM´s with Version 7?

Thx in advance

Reply
0 Kudos
3 Replies
RvdNieuwendijk
Leadership
Leadership

You can upgrade the hardware to version 7 after the creation of the VM like this:

$vm = New-VM -Host $Horst -Name $vmName -DiskMB $HDsize -MemoryMB $RAMsize -NumCPU $ProcNum -GuestID $OSname -Datastore $Datastore -NetworkName $Network -CD -Description $Description
$vmview = $vm | Get-View
if ($vmView.Config.Version -eq "vmx-04") {$vmView.UpgradeVM_Task("vmx-07")}

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
Reply
0 Kudos
admin
Immortal
Immortal

Hi chakoe,

Can you clarify the version of PowerCLI that you are using and the version of the VC or ESX on which you run this command.

Thanks,

Vitali

Reply
0 Kudos
ykalchev
VMware Employee
VMware Employee

Hi,

Since PowerCLI 4.1 we've introduced Version parameter in the New-VM cmdlet. The valid values are listed in VMVersion enum

Now you can create VM and specify the version explicitly:

New-VM -Host $Horst -Name $vmName -DiskMB $HDsize -MemoryMB $RAMsize -NumCPU $ProcNum -GuestID $OSname -Datastore $Datastore -NetworkName $Network -CD -Description $Description -Version v7

By default, the new virtual machine is created with the highest available version.

Regards,

Yasen Kalchev

PowerCLI Dev Team

Yasen Kalchev, vSM Dev Team
Reply
0 Kudos