Forum Discussion
New-ClusterAffinityRule: cmdlet not recognized
Hi Harm_Veenstra, thank you for your answer.
Unfortunately, your advice didn't help as I already have the RSAT failover cluster module installed (I can check by successfully running:
get-cluster -name <clustername>
which is a cmdlet provided by https://learn.microsoft.com/en-us/powershell/module/failoverclusters/?view=windowsserver2022-ps.
In fact, I have all Windows RSAT capabilities installed on my machine; looks like none of them provides any of the 'new' cmdlets:
New-ClusterAffinityRule
Set-ClusterAffinityRule
Get-ClusterAffinityRule
Add-ClusterGroupToAffinityRule
Add-ClusterSharedVolumeToAffinityRule
Remove-ClusterAffinityRule
Remove-ClusterGroupFromAffinityRule
Remove-ClusterSharedVolumeFromAffinityRule
described in the MS article https://learn.microsoft.com/en-us/azure-stack/hci/manage/vm-affinity.
The article shows how to use Windows Admin Center (WAC) for managing basic affinity rules, too. I saw the menu item some weeks ago in WAC, but MS seems to have eliminated it in a newer version 'cause I cannot find it anymore in my WAC GUI.
I must admit that I have some trouble understanding the AntiAffinityClassNames property:
While MS describe it as being of type System.Collections.Specialized.StringCollection (that's what I can read on other pages dealing with how to set affinity rules as well),
Get-ClusterGroup -Cluster 'atndfhcicl01' | get-member -Name 'AntiAffinityClassNames' | fl *
gives me:
TypeName : Deserialized.Microsoft.FailoverClusters.PowerShell.ClusterGroup
Name : AntiAffinityClassNames
MemberType : Property
Definition : Deserialized.System.String[] {get;set;}
To my understanding, this is a little different to the term string collection—but hey, I'm not that expert regarding .net and C++ classes...
The MS article https://learn.microsoft.com/en-us/previous-versions/windows/desktop/mscs/groups-antiaffinityclassnames?redirectedfrom=MSDN gives me the impression that I can simply assign a string (array? In the command result above, there are those brackets after Deserialized.System.String...) value to the AntiAffinityClassNames property of affected virtual machines (VMs) to define an anti-affinity 'rule'.
It would help me a lot if someone could tell me what MS article I can 'trust', and whether it's really that simple to create an affinity rule. In the end, all I want is to avoid two special VMs to run on the same cluster node...
Azure Stack HCI is its own operating system, as the subscription model-based replacement for Hyper-V Server (which was free.)
Unless you're running the Azure Stack HCI hypervisor, you will not see these commandlets.
Cheers,
Lain
- ahinterlAug 24, 2023Brass Contributor
Thank you, LainRobertson.
At least with PS 5.1 on one of the Azure Stack HCI nodes, I had no luck (cmdlet not recognized). I don't want to irritate the machine, so I refrain from installing PS 7.3 which may behave differently.
Maybe someone tell me whether it's sufficient to simply assign a string to a VM's AntiAffinityClassNames property like this:
(Get-ClusterGroup -Name "vm1").AntiAffinityClassNames = 'SeparateVMs' (Get-ClusterGroup -Name "vm2").AntiAffinityClassNames = 'SeparateVMs'to get the VMs separated onto two different cluster nodes?
- LainRobertsonAug 24, 2023Silver Contributor
PS: Windows PowerShell (aka 5.1) is fine.
You don't need PowerShell (aka 7.x) for this at all. In fact, not all shipped modules even work properly with PowerShell.
Cheers,
Lain
- ahinterlAug 24, 2023Brass Contributor
Hi Lain, this is what I get:
Display Name Name Install State
------------ ---- -------------
[X] Failover Clustering Failover-Clustering Installed
[X] Failover Clustering Tools RSAT-Clustering Installed
[X] Failover Cluster Management Tools RSAT-Clustering-Mgmt Installed
[X] Failover Cluster Module for Windows ... RSAT-Clustering-Powe... Installed
[ ] Failover Cluster Automation Server RSAT-Clustering-Auto... Available
[ ] Failover Cluster Command Interface RSAT-Clustering-CmdI... AvailableMaybe it's the last item that I'm missing...
But anyway, even if I can get the cmdlet to run directly on the cluster node itself, I wonder how I can make use of it on a remote management machine (I normally do things in Visual Studio Code there)...
- LainRobertsonAug 24, 2023Silver Contributor
If you're running Azure Stack HCI, you shouldn't need to work with assigning values that way as you ought to have the commandlets you're looking for available to you - assuming you have the failover clustering feature enabled.
Maybe let's check that first.
If you run the following, do you see failover clustering service and the relevant management tools (including the PowerShell module) installed?
Get-WindowsFeature -Name *clus*
If not, then that's why you can't see the newer commandlets.
Cheers,
Lain