On running this powershell script getting an error as uninitialized EOH

Hi

I am running below powershell script using the recipe and on execution getting a error " Namespace error not initialize ;EOH "

Kindly suggest

powershell_script ‘deploy’ do
guard_interpreter :powershell_script
code <<-EOH
$arguments =’-source:package=“C:\Install\pkg\MYCVO\CMSApp.zip”’, ‘-dest:auto’, ‘-setParam:name="IIS’, ‘Web’, ‘Application’, ‘Name",value=“Check”’, ‘- setParam:name="CMSConnectionString-Web.config’, ‘Connection’, ‘String",value="Server=Ericson\SQL2014EXPRESS;’, ‘Database=Test_catia_upgrade;’, ‘User’, ‘Id=catia;’, ‘Password=password1;"’, ‘-verb:sync’,’-enableRule:DoNotDeleteRule’, '-allowUntrusted’
EOH
end

Error is : Namespace error not initialize ;EOH

Thanks in advance

The -setParam sections seem to have some bad quoting in them. I think you’re using some single quotes where you want double quotes instead.

1 Like

@nclemons

Thanks a lot for your reply.

Can you please elaborate with example.Using the same above script

Something like this; I’m not exactly sure about the code so some of the quotes may be wrong:

powershell_script 'deploy' do
  guard_interpreter :powershell_script
  code <<-EOH
    $arguments ='-source:package="C:\Install\pkg\MYCVO\CMSApp.zip"', '-dest:auto', '-setParam:name="IIS", "Web", "Application", "Name",value="Check"', '-setParam:name="CMSConnectionString-Web.config"', "Connection', 'String','value="Server=Ericson\SQL2014EXPRESS";', 'Database=Test_catia_upgrade;', 'User', 'Id=catia;', 'Password=password1;"', '-verb:sync','-enableRule:DoNotDeleteRule', '-allowUntrusted'
  EOH
end