VMware Cloud Community
Paulk99
Enthusiast
Enthusiast

Code Snippet needed for HA options ...

Hi All

We have a pretty massive Powershell deployment script which works really well.

At the moment it will reference a CSV pull all the data in and deploy based on that. Covers Disks, SCSi Adaptors, NICs, Advanced options, Hardening IP, DNS Hot add disable, Tags and all the other tweaking required so it does the lot !! 

However there is a new parameter being added to our service catalogue and i really dont know the PS commands to run the required function so any help as a starter for 10 really really appreciated.

So what i need to do is add a VM to the vCenter HA options for vM over-rides section with a value of Disabled

Any ideas how i can run this in powershell \ powercli..?

Cheers all

Paul

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

You can do that like this.
You have to make sure of course that the VM belongs to the cluster.

Get-VM -Name MyVM | Set-VM -HARestartPriority Disabled -Confirm:$false


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

Reply
0 Kudos
Paulk99
Enthusiast
Enthusiast

Cheers Luc !!

Thats plenty to wrap in to our deployment script.

For sure the VM will be part of a cluster so that wont be an issue.

Happy days will roll it out for testing tomorrow. TBH i was expecting something a lot more complicated !

Paul

Reply
0 Kudos
LucD
Leadership
Leadership

If you want complicated, this is how we did this before the parameter existed.
Makes you appreciate the PowerCLI cmdlets even more :smileygrin:

$clusterName = 'cluster'

$vmName = 'MyVM'


$cluster = Get-Cluster -Name $clusterName

$vm = Get-VM -Name $vmName


$spec = New-Object -TypeName VMware.Vim.ClusterConfigSpec

$vmSpec = New-Object -TypeName VMware.Vim.ClusterDasVmConfigSpec

$vmSpec.Info = New-Object -TypeName VMware.Vim.ClusterDasVmConfigInfo

$vmSpec.Info.Key = $vm.ExtensionData.MoRef

$vmDas = New-Object -TypeName VMware.Vim.ClusterDasVmSettings

$vmDas.RestartPriority = [VMware.Vim.ClusterDasVmSettingsRestartPriority]::disabled

$vmSpec.Info.DasSettings += $vmDas

$spec.DasVmConfigSpec += $vmSpec

$cluster.ExtensionData.ReconfigureCluster($spec, $true)


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

Reply
0 Kudos
Paulk99
Enthusiast
Enthusiast

Ha no thanks our deployments take long enough as it is... I will stick with the one liner !

Reply
0 Kudos