gpt4 book ai didi

c# - Azure 自定义脚本停留在转换状态

转载 作者:行者123 更新时间:2023-12-03 05:52:54 24 4
gpt4 key购买 nike

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

powershell脚本是:

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

这是获取虚拟机并尝试在远程虚拟机上应用此脚本的代码。

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 文件夹中,但 Paint 未打开,并且在 Azure 门户上的状态为扩展名永远设置为“Transitioning”。 (我还确保虚拟机在该目录中有paint,并且执行策略设置为Bypass)。

我做错了什么?

最佳答案

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

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

get-process > c:\1.txt

关于c# - Azure 自定义脚本停留在转换状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45635527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com