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