2014-05-22 61 views
0

我试图运行我的azurewebsite“设置AzureWebsite”没有被识别为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); 
     } 


    } 

以下PowerShell命令,但我得到波纹错误

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

回答

-1

firts问题:你为什么要这样做呢?其次,如果你想这样做,你需要首先导入模块,并且需要安装Powershell工具。导入模块如下PoSh:import-module Azure

+0

我已经安装了Powershell工具,用于Windows PowerShell的Windows Azure Active Directory模块等 –

+0

当我尝试在PowerShell导入模块Azure中运行命令时,它给了我错误“找不到指定的模块“Azure” –

+0

powershell工具有单独的下载:http://azure.microsoft.com/en-us/downloads/请参阅命令行部分 – techmike2kx

相关问题