VMware Cloud Community
bsti
Enthusiast
Enthusiast
Jump to solution

Trying to Change DRS Advanced Options

I'm trying to write a quick Powershell script to change the following DRS Advanced option:

MinPoweredOnCpuCapacity

Basically, the idea is to set it high during work hours, and bump it down during off hours.

I've gotten this far, and feel I'm really close:

connect-viserver

$view = ( Get-View (Get-Cluster Cluster1).Id)

I can see the option I've already set here:

$view.Configuration.DrsConfig.Option

Key Value DynamicType DynamicProperty

--- -


-


-


MinPoweredOnCpuCapacity 90000

Here is how I've tried ot set it:

$opt = New-Object VMWAre.vim.OptionValue

$opt.Key = "MinPoweredOnCpuCapacity"

$opt.Value = 1

$spec = New-Object VMware.VIm.ClusterConfigSpecEx

$spec.DrsConfig = New-Object Vmware.vim.ClusterDrsConfigInfo

$spec.DrsConfig.option = $opt

$view.ReconfigureComputeResource($spec, $true)

This last command fails with the following message:

Exception calling "ReconfigureComputeResource" with "2" argument(s): "A specified parameter was not correct.

DRS advanced option: MinPoweredOnCpuCapacity"

At line:1 char:33

+ $view.ReconfigureComputeResource <<<< ($spec, $true)

+ CategoryInfo : NotSpecified: (Smiley Happy [], MethodInvocationException

+ FullyQualifiedErrorId : DotNetMethodException

Any ideas on how to do this??

Thanks!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Contrary to what the SDK Reference says the value property has to be a string.

This will work

$opt = New-Object VMWAre.vim.OptionValue
$opt.Key = "MinPoweredOnCpuCapacity"
$opt.Value = [string]1
$spec = New-Object VMware.VIm.ClusterConfigSpecEx
$spec.DrsConfig = New-Object Vmware.vim.ClusterDrsConfigInfo
$spec.DrsConfig.option = $opt
$view.ReconfigureComputeResource($spec, $true)

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Contrary to what the SDK Reference says the value property has to be a string.

This will work

$opt = New-Object VMWAre.vim.OptionValue
$opt.Key = "MinPoweredOnCpuCapacity"
$opt.Value = [string]1
$spec = New-Object VMware.VIm.ClusterConfigSpecEx
$spec.DrsConfig = New-Object Vmware.vim.ClusterDrsConfigInfo
$spec.DrsConfig.option = $opt
$view.ReconfigureComputeResource($spec, $true)

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
bsti
Enthusiast
Enthusiast
Jump to solution

That was it. Thank you very much!

0 Kudos
rosarre
Contributor
Contributor
Jump to solution

The information provide is very useful.  My question is do you code for enumerating the contes of the drs rule, the host group and the quest group. This would be helpful to create a baseline of drs rules for monitoring any changes that might occur in the environment.  I will attempt to modify the code provided to get a version for listing, but my skill level for managing these objects is lacking at best.

Thanks

Bob

0 Kudos