Apply host affinity to list of VMs | Nutanix Community
Skip to main content

Is there a way using PowerShell to assign a large list of VMs to run from only specific hosts within an AHV cluster?  Basically is there a way to assign host affinity to a list of VMs?  I found commands for anti-affinity using the CLI but could not find anything related to setting affinity.  

Hi @ebertolasio

I have no guide to share with you, I am afraid. However I found something that could be useful to you, hopefully. Please test this in a lab before using it in production.

REST API / PowerShell Mass VM Affinity Control by Michell Grauwmans.


Thank you, this may be an option in the future.

I ended up working with support and was provided ACLI commands to set/unset affinity for the VMs.

acli vm.affinity_unset <vmname>,<vmname>

acli vm.affinity_set <vmname>,<vname> host_list=<hostUID>,<hostUID>


I didn’t think to mention aCLI to be honest, as you asked for the PowerShell. Glad to hear you were provided with a solution :)