“Set-AzureWebsite”无法识别为cmdlet的名称,

时间:2014-05-22 12:08:03

标签: powershell azure

我正在尝试在我的azurewebsite上运行以下powershell cmdlet

 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);
        }


    }

但我得到了以下错误

  

术语“Set-AzureWebsite”无法识别为cmdlet,函数,脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

1 个答案:

答案 0 :(得分:-1)

第一个问题:你为什么要这样做呢?第二,如果你想这样做,你需要先导入模块,然后需要安装Powershell工具。导入模块如下所示:PoSh:import-module Azure

相关问题