简体   繁体   中英

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

I have an issue with the 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:

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"`

屏幕截图

hello.ps1

You need to put the file in your VM and use the format below:

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

result:

在此处输入图片说明

To run a script from a remote machine to a Linux VM in Azure, use:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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