parse error for the parameters in powershell script

asked 2015-04-27 18:05:33 +0200

anonymous user

Anonymous

I have one script which accepts two parameters: param([string] $urlsrc,[string]dest)

But when I try to launch the windows VM using heat template, cloudbase-init.log reported: executeuserdatascript C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python27\lib\site-packages\cloudbaseinit\plugins\windows\userdatautils.py:58 2015-04-27 13:53:19.530 1788 DEBUG cloudbaseinit.plugins.windows.userdatautils [-] Userdata stderr: Parameter declarations are a comma-separated list of variable names with option

al initializer expressions.

At line:2 char:10

  • [String] <<<< ,

    • CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx

    ception

    • FullyQualifiedErrorId : InvalidFunctionParameter

    executeuserdata_script C:\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python27\lib\site-packages\cloudbaseinit\plugins\windows\userdatautils.py:59 2015-04-27 13:53:19.546 17

I can run the script successfully from powershell command prompt. Could you pls tell me how to fix it? Thanks a lot

edit retag flag offensive close merge delete

Comments

Hi. Could you post the part of the Heat template where the actual powershell script is? Also, it seems you are using a really old cloudbase-init version, consider using the latest version.

cpopa gravatar imagecpopa ( 2015-04-27 19:02:07 +0200 )edit

The script is like: param([String]$urlsrc, [String]$dest) $webclient = New-Object System.Net.webclient $testcode1 = $webclient.downloadstring($urlsrc) -split "\<a\s+" $allsnapshots="$testcode1" |="" select-string="" "\(?<="\">\)(\d+)(.*)SNAPSHOT(?=\/\<)" -allmatches | % { $_.matches } | % { $_.value } |get-unique |sort -descending

celina-yang gravatar imagecelina-yang ( 2015-04-27 20:26:52 +0200 )edit

I checked and found I am using cloudbase-init 1.0.0.0. is this the latest version?

celina-yang gravatar imagecelina-yang ( 2015-04-27 21:04:48 +0200 )edit