C# Azure自定义脚本处于转换状态

C# Azure自定义脚本处于转换状态,c#,.net,powershell,azure,azure-web-app-service,C#,.net,Powershell,Azure,Azure Web App Service,我的azure帐户上有一个虚拟机,我想传递一个简单的powershell脚本,该脚本应该可以打开Microsoft Paint程序 powershell脚本是: & "C:\Windows\system32\mspaint.exe" 这是获取vm并尝试在远程vm上应用此脚本的代码 var testingVm = _azure.VirtualMachines.GetById( "..."); testingVm.Update()

我的azure帐户上有一个虚拟机,我想传递一个简单的powershell脚本,该脚本应该可以打开Microsoft Paint程序

powershell脚本是:

& "C:\Windows\system32\mspaint.exe"  
这是获取vm并尝试在远程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:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.9\Downloads\0文件夹中,bu Paint未打开,并且在Azure门户上,扩展状态永远设置为“转换”。(我还确保vm在该目录中有paint,并且执行策略设置为Bypass)


我做错了什么?

我很确定没有什么错。它会在系统上下文下启动paint(因此您无法在屏幕上看到它),并且它会永远卡在那里。所以我猜它的工作原理和你设计的完全一样(但设计有缺陷)

试着在脚本中做一些有意义的事情(而不是你正在做的事情):


我很确定没有什么不对劲。它会在系统上下文下启动paint(因此您无法在屏幕上看到它),并且它会永远卡在那里。所以我猜它的工作原理和你设计的完全一样(但设计有缺陷)

试着在脚本中做一些有意义的事情(而不是你正在做的事情):


作为一个额外的东西,我怎样才能从这个C#代码向powershell脚本传递参数呢?很遗憾,这帮不了你。从未使用过c#sdk,就像一些额外的东西一样,我怎样才能从这个c#代码向powershell脚本传递参数呢?很遗憾,这帮不了你。从未使用过c#sdk
get-process > c:\1.txt