如何将多个参数传递给Set-AzureRmVMCustomScriptExtension? [英] How can I pass multiple arguments to Set-AzureRmVMCustomScriptExtension?

查看:47
本文介绍了如何将多个参数传递给Set-AzureRmVMCustomScriptExtension?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于将自定义脚本扩展添加到名为

The Azure Cmdlet for adding a Custom Script Extension to a VM named Set-AzureRmVMCustomScriptExtension has an -Argument switch, which states that it accepts a string, but no example of how this is implemented. While it says it can accept multiple arguments, it appears to be for a single argument.

我需要传递多个参数,但是找不到正确的语法.

I need to pass multiple arguments, but can't find the correct syntax to do so.

示例:

$arg1 = "mysitename"
$arg2 = "c:/mydirectorytocreate"

-Argument "$arg1,$arg2"

如何将多个参数传递给

How do I pass multiple arguments to Set-AzureRmVMCustomScriptExtension so I can pass these values to the actual script that needs these values (ex. passing an IIS Site Name and a Directory Path as two separate values).

推荐答案

Set-AzureVMCustomScriptExtension -VM $x -ContainerName 'test' -FileName 'script1.ps1','script2.ps1','script3.ps1' -Run 'script1.ps1' -Argument 'arg1 arg2' 
      | Update-AzureVM  

如果此代码段确实有效,则意味着您需要传递以空格分隔的字符串作为参数.只需确保保留双引号,以使变量正确扩展即可.

If this code snipett actually works then it means you need to pass a space delimited string for your arguments. Just make sure you keep your double quotes so the variables expand properly.

这篇关于如何将多个参数传递给Set-AzureRmVMCustomScriptExtension?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆