简体   繁体   English

将'az vm run-command'与.ps1文件一起使用

[英]Using the 'az vm run-command' with a .ps1 file

I have an issue with the az vm run-command . 我的az vm run-command有问题。

I have got it working inline as follows: 我已经按如下方式内联工作:

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

and: 和:

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

It works. 有用。

But when I try to use a .ps1 file: 但是,当我尝试使用.ps1文件时:

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

I get this issue: 我得到这个问题:

在此处输入图片说明

The documentation says this: 该文档说:

在此处输入图片说明

So I am kind of stuck. 所以我有点卡住了。

You can try to put the file with the following format: --scripts "@hello.ps1"` 您可以尝试使用以下格式放置文件:-- scripts“ @ hello.ps1”`

屏幕截图

hello.ps1

You need to put the file in your VM and use the format below: 您需要将文件放入VM并使用以下格式:

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

result: 结果:

在此处输入图片说明

To run a script from a remote machine to a Linux VM in Azure, use: 要将脚本从远程计算机运行到Azure中的Linux VM,请使用:

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

I had copied the quality-check.pl script in my current location on the remote machine. 我已经在远程计算机上的当前位置复制了quality-check.pl脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM