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 strin
Not sure if there is a difference between the ASM (classic) and ARM version of this cmdlet but for me, I had to do it thus (parameters missing for clarity):
$arguments = "-arg1 'foo' -arg2 'bar' -arg3 'cat'"
Set-AzureRmVMCustomScriptExtension `
-Argument $Arguments `
-Run "SomeScript.ps1"
SomeScript.ps1 would look something like:
param
(
[string]$arg1,
[string]$arg2,
[string]$arg3
)
function SomeFunction
{
Write-Host $arg1
Write-Host $arg2
Write-Host $arg3
#Do something here...
}
SomeFunction -arg1 $arg1 -arg2 $arg2 -arg3 $arg3 #Call the function from within SomeScript.ps1
If you could actually see the output of Write-Host when run from a Custom Script Extension, it would result in an output of :
foo
bar
cat
HTH.