I have several VM with names: app, db and etc.
How I can change DRS VM overrides using PowerCLI?
Several of these are HA settings, not DRS.
But in any case, you could do something like this
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
You can use the Set-VM cmdlet with the DrsAutomationLevel parameter.
Something like this
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How can I get current VM overrides settings for VM, in (Get-VM -Name app).DrsAutomationLevel - no information
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
------------------------- 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.
-------------------------------------------------------------------------
That's the latest version.
And the following is not returning 'AsSpecifiedByCluster'?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PS C:\> Get-VM -Name app | Select Name,DrsAutomationLevel
Name DrsAutomationLevel
---- ------------------
app Manual
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
Can you tell me which ExtensionData you need to watch?
Maybe an example?
Which properties do you want to report on?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Several of these are HA settings, not DRS.
But in any case, you could do something like this
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
Thank you for what you need!
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
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
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 ?
You might have a look at https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Setting-VM-overrides-through-PowerCLI/...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference