New Question

Revision history [back]

click to hide/show revision 1
initial version

How to pass parameters to powershell script in userdata?

My heat template is like:

  type: OS::Nova::Server 
  image: {get_param: imagever } 
 flavor: m1.large 
 key_name: test 
   - port: { get_resource: publicport } 
user_data_format: RAW 
    template: | 

       testps "$srcurl" "$dest"   -Verbose

       $dest: { get_param: target_location }
       $srcurl: { get_param: url_src }
       testps: { get_file: test1.ps1 }

test1.ps1 :

param([String]$src, [String]$dest) 
Write-Host "url is:" + $src 
 write-host "dest is:" + $dest

But cloudbase-init.log reported: executeuserdatascript C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python27\lib\site-packages\cloudbaseinit\plugins\windows\ 2015-04-27 18:40:06.905 1788 DEBUG [-] Userdata stderr: The term 'param' is not recognized as the name of a cmdlet, function, script fi

le, or operable program. Check the spelling of the name, or if a path was inclu

ded, verify that the path is correct and try again.

At C:\Users\cloudbase-init\appdata\local\temp\6ea2afb5-645b-430c-91a2-a67c3201f

5db.ps1:7 char:7

param <<<< ([String]$src, [String]$dest) CategoryInfo : ObjectNotFound: (param:String) [], CommandNotFou

ndException FullyQualifiedErrorId : CommandNotFoundException

So what is the correct way to pass parameter to a powershell script using heat template?