2017-08-11 19 views
0

我的Azure帐户上有一台虚拟机,我想传递一个简单的应该只打开Microsoft Paint程序的powershell脚本。Azure自定义脚本停留在转换状态

PowerShell脚本是:

& "C:\Windows\system32\mspaint.exe" 

这是提取的虚拟机,并试图在远程VM应用此脚本的代码。

var testingVm = _azure.VirtualMachines.GetById(
      "..."); 
     testingVm.Update() 
      .DefineNewExtension("InstallSoftware") 
      .WithPublisher("Microsoft.Compute") 
      .WithType("CustomScriptExtension") 
      .WithVersion("1.9") 
      .WithPublicSetting("fileUris", new string[] 
      { 
       "https://.../powershellscripts/OpenPaint.ps1" 
      }) 
      .WithProtectedSetting("Url", "https://.../powershellscripts/gource-0.42-setup.exe") 
      .WithProtectedSetting("commandToExecute", "powershell -ExecutionPolicy Bypass -File OpenPaint.ps1") 
      .Attach() 
      .Apply(); 

的文件会下载和脚本被正确地放置在C:\包\插件\ Microsoft.Compute.CustomScriptExtension \ 1.9 \下载\ 0文件夹,BU涂料是不公开的,在Azure的门户网站的状态永远设置为“过渡”。 (我也确保vm已经在该目录中绘制,并且执行策略被设置为Bypass)。

我在做什么错?

回答

2

我很确定没有错。它在系统环境下启动绘画(因此你无法在屏幕上看到它),并且它永远停留在那里。所以我想它的工作原理与您的设计完全相同(但设计有缺陷)。

刚刚尝试做脚本(而不是你在做什么)有意义的事:

get-process > c:\1.txt 
+0

正如额外的事情,我怎么会能够从这个C#代码参数传递给PowerShell脚本? – Iason

+0

不能帮你那么伤心。从来没有用过c#sdk – 4c74356b41