VMware Cloud Community
thb_
Enthusiast
Enthusiast
Jump to solution

VMware DRS / virtual machine options

i would like to extract the vmware drs / virtual machine options via powershell.

Does anybody know a way to do that?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Ok, I understand.

The Behavior property is apparently not valid if the Enabled property is set to $false.

And since I don't have any guests where the DRS is set to "disabled" I didn't notice that before.

This updated script should do the trick.

$cluster = Get-Cluster <cluster-name>| Get-View
Write-Host "Default DRS behaviour : " $cluster.ConfigurationEx.DrsConfig.DefaultVmBehavior
foreach($vmConfig in $cluster.ConfigurationEx.DrsVmConfig){
	$vm = Get-View -Id $vmConfig.Key
	if(-not $vmConfig.Enabled){$state = "Disabled"}
	else {$state = $vmConfig.Behavior}
	Write-Host "`t" $vm.Name $state
}


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

You can do that this way

$cluster = Get-Cluster <cluster-name> | Get-View
Write-Host "Default DRS behaviour : " $cluster.ConfigurationEx.DrsConfig.DefaultVmBehavior
foreach($vmConfig in $cluster.ConfigurationEx.DrsVmConfig){
  $vm = Get-View -Id $vmConfig.Key
  Write-Host "`t" $vm.Name $vmConfig.Behavior
}


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

thb_
Enthusiast
Enthusiast
Jump to solution

thanks but the output lists the server where the default is not set:

Server where Automation Level is disabled are listed as "fullyAutomated".

All other servers are not listed...

any ideas?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

The script runs against a cluster not a server, since you define the DRS settings for a cluster not a server.

On the VMware DRS form you define the default setting.

On the Virtual Machine Options form you can override the default cluster DRS settings per guest.

Could you perhaps include your DRS settings and what the script displays ?


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

0 Kudos
thb_
Enthusiast
Enthusiast
Jump to solution

thanks but the output lists the server where the default is not set:

Server where Automation Level is disabled are listed as "fullyAutomated".

All other servers are not listed...

any ideas?

the output lists the VMs ( not the server as i wrote before ) where the default is not set.

Example: Cluster DRS Setting ( default = fully automated ) for VM1 is disabled.

Script lists:

Default DRS behaviour : fullyAutomated

VM1 fullyAutomated

but VM1 is set to disabled.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, I understand.

The Behavior property is apparently not valid if the Enabled property is set to $false.

And since I don't have any guests where the DRS is set to "disabled" I didn't notice that before.

This updated script should do the trick.

$cluster = Get-Cluster <cluster-name>| Get-View
Write-Host "Default DRS behaviour : " $cluster.ConfigurationEx.DrsConfig.DefaultVmBehavior
foreach($vmConfig in $cluster.ConfigurationEx.DrsVmConfig){
	$vm = Get-View -Id $vmConfig.Key
	if(-not $vmConfig.Enabled){$state = "Disabled"}
	else {$state = $vmConfig.Behavior}
	Write-Host "`t" $vm.Name $state
}


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

0 Kudos