Forum Discussion
New-ClusterAffinityRule: cmdlet not recognized
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?
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, 2023Copper 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
Right, so this is all coming together now that I know you were looking to run the commands remotely. Probably my poor attention span, but I didn't spot that in your earlier posts.
Okay, so you can still do things remotely. It just requires some preparation beforehand.
# Create the new session. Note: You may need to exclude -UseSSL if you haven't configured secure WinRM; $Session = New-PSSession -ComputerName rpfile02.robertsonpayne.com -UseSSL; # Load the FailoverClusters module into that remote session prior to importing the session. Invoke-Command -Session $Session -ScriptBlock { Import-Module -Name FailoverClusters }; # Now, import the session. There's various parameters you can use here but I'm going with the simple approach. Import-PSSession -Session $Session;
You can now run New-ClusterAffinityRule and so forth.
Cheers,
Lain