【发布时间】:2017-08-11 12:42:20
【问题描述】:
我的 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 在那个目录中有画,并且执行策略设置为 Bypass)。
我做错了什么?
【问题讨论】:
标签: c# .net powershell azure azure-web-app-service