是否可以从云中的辅助角色运行 azure powershell cmdlet?
如果是这样,有没有人设法做到这一点,并且可以就如何进行所有设置提供某种解释?
到目前为止我有这个,但它不会工作。
using (PowerShell powerShell = PowerShell.Create())
{
powerShell.AddCommand("Set-ExecutionPolicy");
powerShell.AddParameter("ExecutionPolicy", "RemoteSigned");
Collection<PSObject> output = powerShell.Invoke();
ProcessPowerShellOutput(output);
powerShell.AddCommand("Import-Module");
powerShell.AddParameter("Name", "Azure");
output = powerShell.Invoke();
ProcessPowerShellOutput(output);
powerShell.AddCommand("Import-AzurePublishSettingsFile");
powerShell.AddParameter("PublishSettingsFile", @"<PATH>");
output = powerShell.Invoke();
ProcessPowerShellOutput(output);
powerShell.AddCommand("Set-AzureSubscription");
powerShell.AddParameter("SubscriptionName", @"SUB NAME");
output = powerShell.Invoke();
ProcessPowerShellOutput(output);
powerShell.AddCommand("Set-AzureRole");
powerShell.AddParameter("ServiceName", @"deploymentconfigtest");
powerShell.AddParameter("Slot", @"Production");
powerShell.AddParameter("RoleName", @"DummyWorkerRole");
powerShell.AddParameter("Count", 2);
output = powerShell.Invoke();
ProcessPowerShellOutput(output);
}
这是我使用 powershell 控制台运行的,它在那里运行良好。
任何帮助表示赞赏。
谢谢
史蒂夫