[chef] Get return value from powershell into attribute


Chronological Thread 
  • From: Iain Prior < >
  • To: " " < >
  • Subject: [chef] Get return value from powershell into attribute
  • Date: Sun, 10 Aug 2014 08:14:14 +0100
  • Accept-language: en-US, sv-SE
  • Acceptlanguage: en-US, sv-SE

Hi guys

 

I have been bashing my head against this for hours, and I’m sure there is something simple and obvious that I just don’t know..

 

I want to run a powershell script to get the FileVersion attribute of a file and save that into a chef attribute on the server.

 

Here is the recipe I’m struggling with. Please help?

 

::Chef::Resource::PowershellScript.send(:include, Chef::Mixin::PowershellOut)

 

powershell_script "read-version" do

  cwd Chef::Config[:file_cache_path]

  code <<-EOH

    sleep 5

    [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\\Program Files\\xxx\\yyy\\zzz.dll").FileVersion | fl

   Return

  EOH

  node.default[:gac_integration][:version] = powershell_out(code).stdout

  node.default[:gac_integration][:version] = powershell_out(code).stderr

end

 

Here is the error I am getting..

 

At line:1 char:58 + [System.Diagnostics.FileVersionInfo]::GetVersionInfo(C:\Program Files\Gulf A ... + ~ Missing ')' in method call. At line:1 char:58 + [System.Diagnostics.FileVersionInfo]::GetVersionInfo(C:\Program Files\Gulf A ... + ~~~~~~~~~~ Unexpected token 'C:\Program' in _expression_ or statement. At line:1 char:130 + ... Integration.dll).FileVersion | fl + ~ Unexpected token ')' in _expression_ or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx ception + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

 

 

Many regards

Iain

 




Archive powered by MHonArc 2.6.16.

§