I had a need to change the host isolation response of all the VMs in a VMware ESX cluster. The ESX hosts are 3.0.1 and the VirtualCenter server is 2.0.2.

Since the beautiful VI client only allows changing one VM setting at a time, it would take forever to change all 1,500 VMs that I need to adjust across 4 clusters and 2 VC servers.

Powershell scripts turned out to be the answer. Here is a script that will change the isolation response to “Leave powered on” by changing the property powerOffOnIsolation to false. This script only works against VirtualCenter 2.0.x. For a script that works against VC 2.5, check out this post in the VMware forums.

If this script doesn’t work, make sure you change the “Connect-VIServer” line to connect to the proper hostname, and the “Get-Cluster” line to use the proper cluster.

Also, if the VC task fails saying “a specified parameter was incorrect”, try changing the Operation to “edit” instead of “add”.

Connect-VIServer vdi_vc_bdc
$cs = Get-Cluster "Cluster4"
$csadv = get-view $cs.id
$allvms = $cs | Get-VM

$i = 0
$csspec = new-object VMware.Vim.ClusterConfigSpec

foreach ($vm in $allvms) {
  $csspec.dasVMConfigSpec += new-object VMware.Vim.ClusterDasVmConfigSpec
  $csspec.dasVMConfigSpec[$i].info = new-object Vmware.Vim.ClusterDasVmConfigInfo
  $csspec.dasVMConfigSpec[$i].Info.Key = ($vm | get-view).moref
  $csspec.dasVMConfigSpec[$i].Operation = "add"
  $csspec.dasVMConfigSpec[$i].info.powerOffOnIsolation = $false

  $i++
}

$csadv.ReconfigureCluster_Task($csspec,$true)

Good luck!

No related posts.

Tags: , ,

No comments

Comments feed for this article

Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>