Automation

 View Only
Expand all | Collapse all

How to upgrade guest virtual hardware using PowerCLI?

  • 1.  How to upgrade guest virtual hardware using PowerCLI?

    Posted Jun 26, 2009 03:33 PM

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

    Thanks,

    Gregor



  • 2.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Broadcom Employee
    Posted Jun 26, 2009 03:36 PM

    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



  • 3.  RE: How to upgrade guest virtual hardware using PowerCLI?
    Best Answer

    Posted Jun 27, 2009 11:05 AM

    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 ;-).



  • 4.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted Jul 22, 2009 02:31 PM


  • 5.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted May 18, 2011 07:58 PM

    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.



  • 6.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted Jun 26, 2009 04:40 PM

    Try

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



  • 7.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted May 19, 2011 02:49 AM

    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
    //


  • 8.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted May 19, 2011 05:52 AM

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



  • 9.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted May 19, 2011 06:13 AM

    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
    //


  • 10.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted Aug 01, 2011 09:24 PM

    This works in my environment (ESXi 4.1):

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



  • 11.  RE: How to upgrade guest virtual hardware using PowerCLI?

    Posted Jan 22, 2012 10:00 PM

    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.