2

我对az vm run-command.

我让它内联工作如下:

$resource_name="winsecagentdev2"
$resource_group="russellmccloydev"

和:

az vm run-command invoke `
-g "${resource_group}" `
-n "${resource_name}" `
--command-id 'RunPowerShellScript' `
--scripts "Write-Output 'testing russ'"

有用。

但是当我尝试使用 .ps1 文件时:

az vm run-command invoke `
-g "${resource_group}" `
-n "${resource_name}" `
--command-id 'RunPowerShellScript' `
--scripts @{'hello.ps1'} `
--parameters @{ "test" = "russell" }

我得到这个问题:

在此处输入图像描述

文档是这样说的:

在此处输入图像描述

所以我有点卡住了。

4

3 回答 3

2

您可以尝试使用以下格式放置文件:-- scripts "@hello.ps1"`

截屏

你好.ps1

于 2018-07-25T05:46:24.487 回答
1

您需要将文件放入您的虚拟机并使用以下格式:

--scripts "C:\test\hello.ps1"

结果:

在此处输入图像描述

于 2018-07-25T03:33:51.083 回答
1

若要在 Azure 中将脚本从远程计算机运行到 Linux VM,请使用:

az vm run-command invoke myResourceGroup -n myVm --command-id RunShellScript --scripts "@quality-check.pl" 

我已将脚本复制quality-check.pl到远程计算机上的当前位置。

于 2018-09-10T05:36:43.593 回答