VMware Cloud Community
wbru
Contributor
Contributor

Powercli to migrate VM's in a cluster with Partial DRS

I use a for loop in Powercli  to:

- step though each VM-Host in a cluster

- migrate the VM"s off it and then put VM-Host into  Maintenance mode.

Before going into Maintenance mode, the VM's need to be migrated off the VM-Host.

Since the cluster uses "Partial DRS" , I've been going to the cluster's DRS tab (  in the Vsphere GUI )  and choosing "Apply Recommedations" . Then

the powered on VM's  are migrated to the available VM-Hosts. 

Is there a powercli way to migrate the VM's  when using "Partial DRS" ?

Thanks,

wbru

Tags (1)
0 Kudos
1 Reply
LucD
Leadership
Leadership

Not with a cmdlet afaik, but you can use the API method ApplyRecommendation

Like this

$clusterName = 'Cluster1'

$cluster = Get-Cluster -Name $clusterName

$cluster.ExtensionData.DrsRecommendation | %{

    $cluster.ExtensionData.ApplyRecommendation($_.Key)

}


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

0 Kudos