VMware Cloud Community
GregorSm
Contributor
Contributor
Jump to solution

How to upgrade guest virtual hardware using PowerCLI?

Is it possible to upgrade virtual machine hardware from version 4 to 7 in PowerShell?

Thanks,

Gregor

Reply
0 Kudos
1 Solution

Accepted Solutions
ICT-Freak
Enthusiast
Enthusiast
Jump to solution

I created a script that will upgrade all your templates to the new hardware level see: http://ict-freak.nl/2009/06/27/powercli-upgrading-vhardware-to-vsphere-part-1-templates.

The next step is to capture the VM's ip-address, upgrade the vHardware and put the ip-address back to the VM. This step is a little bit harder but I hope to found it soon ;-).

View solution in original post

Reply
0 Kudos
10 Replies
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Keep an eye on this blog, he will be releasing the script which does this over the next couple of days I believe....

http://ict-freak.nl/

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
admin
Immortal
Immortal
Jump to solution

Try

Get-VM yourvm | Get-View | % { $_.UpgradeVM($null) }

ICT-Freak
Enthusiast
Enthusiast
Jump to solution

I created a script that will upgrade all your templates to the new hardware level see: http://ict-freak.nl/2009/06/27/powercli-upgrading-vhardware-to-vsphere-part-1-templates.

The next step is to capture the VM's ip-address, upgrade the vHardware and put the ip-address back to the VM. This step is a little bit harder but I hope to found it soon ;-).

Reply
0 Kudos
WHochradel
Contributor
Contributor
Jump to solution

I am having a hard time upgrading the Virtual Hardware with this method.

Get-VM yourvm | Get-View | % { $_.UpgradeVM($null) }

Whether the VM is powered on or off I get a message in vCenter that the operation can not be performed in the current state.

Any thoughts, and also thoughts around the login and let drivers install part as well?  Thanks to all in advance.

Reply
0 Kudos
nava_thulasi39
Jump to solution

Hi,

I get different error

//

[vSphere PowerCLI] C:\Powercli> $vm | get-view | %{ $_.upgradevm($null)}
Exception calling "UpgradeVM" with "1" argument(s): "The attempted operation ca
nnot be performed in the current state (Powered On)."
At line:1 char:33
+ $vm | get-view | %{ $_.upgradevm <<<< ($null)}
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
//
If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Is the VM powered on, like the error message seems to indicate ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
nava_thulasi39
Jump to solution

Hi LucD,

Thanks for the quick reply.

The VM is poweredOn.

Even PoweredOff status, the error message is slight different.

//

[vSphere PowerCLI] C:\Powercli> get-vm Windowsxp | get-view | % { $_.upgradevm(
null) }
Exception calling "UpgradeVM" with "1" argument(s): "The operation is not allow
ed in the current state."
At line:1 char:47
+ get-vm Windowsxp | get-view | % { $_.upgradevm <<<< ($null) }
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
//
If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos
BCBSFMark
Contributor
Contributor
Jump to solution

This works in my environment (ESXi 4.1):

Get-VM $vm | Get-View | % { $_.UpgradeVM("vmx-07") }

Reply
0 Kudos
vmbru
Enthusiast
Enthusiast
Jump to solution

You'd think this would be a feature part of the Scheduled Task in vCenter.

If using vSphere 5 and vCenter (let's say the VM is called Fax Server):

UpgradeHW.ps1

---

Set-ExecutionPolicy RemoteSigned
Connect-VIServer yourvcenterservernamehere -User YourUserNamehere -Password YourPassWordhere

#Stop the VM
Get-VM "Fax Server" | Stop-VM -Confirm:$false
Start-Sleep -Seconds 120

#Upgrade the VM
Get-VM "Fax Server" | Get-View | % { $_.UpgradeVM("vmx-08") }
Start-Sleep -Seconds 120

#Power-up the upgraded VM
Start-VM -VM "Fax Server"

-----

Figure 2 minutes for it to shutdown then start upgrade, then within 2 minutes power it up.  Try it out.

Put it in a bat file called UpgradeHW.bat

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSconsolefile "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -command C:\scripts\UpgradeHW.ps1

Have fun.

Reply
0 Kudos