Reputation: 768
I am trying to run following powershell cmdlet on my azurewebsite
public string RunPowerShellScript()
{
try
{
RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
runspace.Open();
RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
Pipeline pipeline = runspace.CreatePipeline();
//Here's how you add a new script with arguments
Command myCommand = new Command("Set-AzureWebsite");
myCommand.Parameters.Add("Name", "rmssimple");
myCommand.Parameters.Add("HostNames ", "@('test.posxyz.com', 'xyz.com')");
pipeline.Commands.Add(myCommand);
var results = pipeline.Invoke();
return Content(results[0].ToString());
}
catch (Exception ex)
{
return Content(ex.Message);
}
}
but i get bellow error
The term 'Set-AzureWebsite' 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.
Upvotes: 0
Views: 1802
Reputation: 495
firts question : why do you wan tto do it like that? second, if you want to do it , you need to import the module first and the Powershell tools need to be installed. Importing the module is as follwos in PoSh : import-module Azure
Upvotes: -1