I have a DNS name for a cluster which has few nodes on which services are running. I wrote powershell script first which is giving me node on which provided service is running and its state. Script uses Get-ClusterResource command Then I wrote python script which is executing this powershell. When I am running powershell script I am getting the node and its state. But when I am ruuning the powershell script from python I am getting error that:
Get-ClusterResource : The term 'Get-ClusterResource' is not recognized as the
name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is
correct and try again.
I tried to use import-module failovercluster
but did not get success.
Please let me know where I am wrong and if its not possible then I am searching for python lib to achieve the same.
Few understandings of me about cluster:
- We can not create PSSession
for cluster.
I am running powershell script this way:
subprocess.check_output(["powershell.exe", '-ExecutionPolicy', 'Unrestricted', self.win_cluster_handling() + " -Cluster_Name " + self.cluster_name + " -ClusterNode_Action Stop-Cluster" + " -Service_Name " + self.service_name + " -Username " + self.username + " -Password " + self.password])
Did you include Import-module FailoverClusters
in your script also?
Have a look at this question
One suggestion is updating to PowerShell v3.0 or later.