VMware Cloud Community
kluken
Contributor
Contributor

Automate scheduling hardware upgrade on 5.1U1

I saw that someone posted how to set the properties on a vm to schedule the the hardware upgrade when there has been a clean os shutdown. I am a novice at powershell, but threw this script together that will automate this for you.

It assumes your windows log on account has permission to vcenter and you have powercli installed. It will prompt you for the vcenter name then for the cluster name, if you leave out cluster it will do all powered on VMs that are not at vmx-09 and schedule them for update and next clean reboot. It will display on the screen which VMs it is updating. Hope this helps make your busy day a little easier.

0 Kudos
2 Replies
athurston
Enthusiast
Enthusiast

Almost works although i get this when trying to run it any ideas does the script need to be placed in a directory containing the files??

Scheduling hardware upgrade for 12345678

New-Object : Cannot find type [VMware.Vim.ScheduledHardwareUpgradeInfo]: make sure the assembly containing this type is loaded.

At C:\...\vmhardware.ps1:69 char:50

+         $spec.ScheduledHardwareUpgradeInfo = New-Object <<<<  VMware.Vim.ScheduledHardwareUpgradeInfo

    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException

    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

Property 'scheduledHardwareUpgradeStatus' cannot be found on this object; make sure it exists and is settable.

At C:\Users\...\vmhardware.ps1:70 char:38

+         $spec.ScheduledHardwareUpgradeInfo. <<<< scheduledHardwareUpgradeStatus = 'pending'

    + CategoryInfo          : InvalidOperation: (scheduledHardwareUpgradeStatus:String) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

Property 'upgradePolicy' cannot be found on this object; make sure it exists and is settable.

At C:\Users\...\vmhardware.ps1:71 char:38

+         $spec.ScheduledHardwareUpgradeInfo. <<<< upgradePolicy = 'onSoftPowerOff'

    + CategoryInfo          : InvalidOperation: (upgradePolicy:String) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

Property 'versionKey' cannot be found on this object; make sure it exists and is settable.

At C:\Users\.....\vmhardware.ps1:72 char:38

+         $spec.ScheduledHardwareUpgradeInfo. <<<< versionKey = 'vmx-09'

    + CategoryInfo          : InvalidOperation: (versionKey:String) [], RuntimeException

    + FullyQualifiedErrorId : PropertyNotFound

Type  : Task

Value : task-5830

0 Kudos
kluken
Contributor
Contributor

Make sure you have latest PowerCLI 5.1 Release 2

0 Kudos