VMware Cloud Community
PichuginDK
Contributor
Contributor
Jump to solution

DRS VM Overrides

I have several VM with names: app, db and etc.

How I can change DRS VM overrides using PowerCLI?

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Several of these are HA settings, not DRS.
But in any case, you could do something like this

$clusterName = 'cluster'

Get-Cluster -Name $clusterName -PipelineVariable cluster |

Get-VM -PipelineVariable vm |

Select @{N='Cluster';E={$cluster.Name}},

    @{N='VM';E={$_.Name}},

    @{N='DRS Automation Level';E={$_.DrsAutomationLevel}},

    @{N='VM Restart Priority';E={$_.HARestartPriority}},

    @{N='Additional Delay';E={

        $script:orch = $cluster.ExtensionData.ConfigurationEx.VmOrchestration |

            where{$_.Vm -eq $vm.ExtensionData.MoRef} |

            Select -ExpandProperty VmReadiness

        if(-not $script:orch){

            $script:orch = $cluster.ExtensionData.ConfigurationEx.Orchestration.DefaultVmReadiness

        }

        $script:orch.PostReadyDelay}},

    @{N='After Timeout';E={

        $script:ha = $cluster.ExtensionData.ConfigurationEx.DasVmConfig |

            where{$_.Key -eq $vm.ExtensionData.MoRef} |

            Select -ExpandProperty DasSettings

        if(-not $script:ha){

            $script:ha = $cluster.ExtensionData.ConfigurationEx.DasConfig.DefaultVmSettings

        }

        $script:ha.RestartPriorityTimeout}},

    @{N='Host Isolation';E={$_.HAIsolationResponse}},

    @{N='Permanent Device Loss';E={$script:ha.VmComponentProtectionSettings.VmStorageProtectionForPDL}}


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

View solution in original post

16 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the Set-VM cmdlet with the DrsAutomationLevel parameter.

Something like this

Get-VM -Name app | Set-VM -DrsAutomationLevel Disabled -Confirm:$false


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

PichuginDK
Contributor
Contributor
Jump to solution

How can I get current VM overrides settings for VM, in (Get-VM -Name app).DrsAutomationLevel  - no information

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

When there is no explicit setting for a VM, it should say 'AsSpecifiedByCluster', in other words, the cluster default.

Which PowerCLI version are you using?
Do a

Get-Module -Name VMware.PowerCLI -ListAvailable


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

Reply
0 Kudos
PichuginDK
Contributor
Contributor
Jump to solution

-------------------------    Importetd Module   -------------------------

   Get-FunctionVersion                      -    0.0.-1.

   Microsoft.PowerShell.Management          -    3.1.0.

   Microsoft.PowerShell.Security            -    3.0.0.

   Microsoft.PowerShell.Utility             -    3.1.0.

   New-PercentageBar                        -    0.0.-1.

   PowerNSX                                 -    3.0.1118.

   PSReadline                               -    1.2.-1.

   Start-SleepProgress                      -    0.0.-1.

   VAMI                                     -    2.0.0.

   vDocumentation                           -    2.4.0.

   Vi-Module                                -    1.4.7.

   Vi-SDRS                                  -    0.0.-1.

   VMware.Community.CISTag                  -    1.0.0.

   VMware.DeployAutomation                  -    6.7.0.

   VMware.ImageBuilder                      -    6.7.0.

   VMware.PowerCLI                          -    11.5.0.

   VMware.Vim                               -    6.7.0.

   VMware.VimAutomation.Cis.Core            -    11.5.0.

   VMware.VimAutomation.Cloud               -    11.0.0.

   VMware.VimAutomation.Common              -    11.5.0.

   VMware.VimAutomation.Core                -    11.5.0.

   VMware.VimAutomation.Hcx                 -    11.5.0.

   VMware.VimAutomation.HorizonView         -    7.10.0.

   VMware.VimAutomation.License             -    11.3.0.

   VMware.VimAutomation.Nsxt                -    11.5.0.

   VMware.VimAutomation.PCloud              -    10.0.0.

   VMware.VimAutomation.Sdk                 -    11.5.0.

   VMware.VimAutomation.Security            -    11.0.0.

   VMware.VimAutomation.Srm                 -    11.5.0.

   VMware.VimAutomation.Storage             -    11.5.0.

   VMware.VimAutomation.StorageUtility      -    1.3.0.

   VMware.VimAutomation.Vds                 -    11.2.0.

   VMware.VimAutomation.Vmc                 -    11.5.0.

   VMware.VimAutomation.vROps               -    10.0.0.

   VMware.VumAutomation                     -    6.5.1.

   vNugglets.Utility                        -    1.2.0.

   Write-Menu                               -    0.0.-1.

-------------------------------------------------------------------------

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That's the latest version.
And the following is not returning 'AsSpecifiedByCluster'?

Get-VM -Name app | Select Name,DrsAutomationLevel


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

Reply
0 Kudos
PichuginDK
Contributor
Contributor
Jump to solution

PS C:\> Get-VM -Name app | Select Name,DrsAutomationLevel

Name DrsAutomationLevel

---- ------------------

app             Manual

but I do not see these parameters
VM-DRS.jpg
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That property indeed only shows the value of the Automation level field.

If you need to report on other settings, you will have to go into the ExtensionData property.


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

Reply
0 Kudos
PichuginDK
Contributor
Contributor
Jump to solution

Can you tell me which ExtensionData you need to watch?

Maybe an example?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Which properties do you want to report on?


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

Reply
0 Kudos
PichuginDK
Contributor
Contributor
Jump to solution

VM-DRS2.jpg

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Several of these are HA settings, not DRS.
But in any case, you could do something like this

$clusterName = 'cluster'

Get-Cluster -Name $clusterName -PipelineVariable cluster |

Get-VM -PipelineVariable vm |

Select @{N='Cluster';E={$cluster.Name}},

    @{N='VM';E={$_.Name}},

    @{N='DRS Automation Level';E={$_.DrsAutomationLevel}},

    @{N='VM Restart Priority';E={$_.HARestartPriority}},

    @{N='Additional Delay';E={

        $script:orch = $cluster.ExtensionData.ConfigurationEx.VmOrchestration |

            where{$_.Vm -eq $vm.ExtensionData.MoRef} |

            Select -ExpandProperty VmReadiness

        if(-not $script:orch){

            $script:orch = $cluster.ExtensionData.ConfigurationEx.Orchestration.DefaultVmReadiness

        }

        $script:orch.PostReadyDelay}},

    @{N='After Timeout';E={

        $script:ha = $cluster.ExtensionData.ConfigurationEx.DasVmConfig |

            where{$_.Key -eq $vm.ExtensionData.MoRef} |

            Select -ExpandProperty DasSettings

        if(-not $script:ha){

            $script:ha = $cluster.ExtensionData.ConfigurationEx.DasConfig.DefaultVmSettings

        }

        $script:ha.RestartPriorityTimeout}},

    @{N='Host Isolation';E={$_.HAIsolationResponse}},

    @{N='Permanent Device Loss';E={$script:ha.VmComponentProtectionSettings.VmStorageProtectionForPDL}}


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

PichuginDK
Contributor
Contributor
Jump to solution

Thank you for what you need!

Reply
0 Kudos
PichuginDK
Contributor
Contributor
Jump to solution

Everything turned out to be simpler, you can use the "code capture", which is in vSphere HTML5 Web Client

vSphere HTML5 Web Client | VMware Flings

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I don't see how this is related?
Code Capture provides code for a single view of 1 VM, not the logic to get the values for all VMs in a cluster.


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

Reply
0 Kudos
terametrix
Contributor
Contributor
Jump to solution

Hello:

Regarding this same topic, can someone provide some guidance on how to set parameters for VM Overrides using powercli ? Like say VM Readiness - Ready condition to poweredOn for example ?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Reply
0 Kudos