4 Replies Latest reply on Aug 20, 2019 2:19 PM by Paulk99

    Code Snippet needed for HA options ...

    Paulk99 Novice

      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

        • 1. Re: Code Snippet needed for HA options ...
          LucD Guru
          Community WarriorsUser ModeratorsvExpert

          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

          • 2. Re: Code Snippet needed for HA options ...
            Paulk99 Novice

            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

            • 3. Re: Code Snippet needed for HA options ...
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

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

               

              $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)

              • 4. Re: Code Snippet needed for HA options ...
                Paulk99 Novice

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