Automatically Set Preferred Node for a Cluster

Automatically set a preferred node for all resources in a cluster.

John Savill

September 21, 2014

1 Min Read
virtual machines

Q: I arranged virtual machines on specific nodes in my cluster. When possible, I want the virtual machines to always run on the current node. How can I easily configure the current node as the preferred node?

A: In one of my labs, I have two nodes and I place certain virtual machines on certain hosts. I wanted the virtual machines to always be on those nodes when possible. An easy solution is to set the preferred owner on the resource group and configure the failback to enabled. Move the virtual machines to the desired nodes in the cluster, then run the following PowerShell code, which will set the prefered owner to the current owner and enable failback. You could remove the check for VirtualMachine group type, to set preferred for any type of resource group.

$ClusVMs = Get-ClusterGroup | ? { $_.GroupType –eq "VirtualMachine" } Foreach ($ClusVM in $ClusVMs){    $ClusVMCurrentOwner = $ClusVM.OwnerNode.Name    Set-ClusterOwnerNode -Group $ClusVM $ClusVMCurrentOwner    (Get-ClusterGroup -Name $ClusVM.Name).AutoFailbackType = 1}

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like