Click here to Skip to main content
15,880,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm trying to execute the Get-ClusterGroup cmdlet from C# 4.0. I've used the following code

InitialSessionState iss = InitialSessionState.CreateDefault();
iss.ImportPSModule(new string[] { "failoverclusters"});

Runspace myRunSpace = RunspaceFactory.CreateRunspace(iss);
myRunSpace.Open();

Pipeline pipeLine = myRunSpace.CreatePipeline();

Command myCommand = new Command("Get-ClusterGroup");
pipeLine.Commands.Add(myCommand);

Console.WriteLine("Invoking Command");
Collection<psobject> commandResult = pipeLine.Invoke();

foreach (PSObject resultObject in commandResult)
{
Console.WriteLine(resultObject.ToString());
}
myRunSpace.Close();

But getting the following error

The term 'Get-ClusterGroup' 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.


It will be great if someone can show me the where I'm missing the logic or where is the problem in my code
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900