Hey, no monkeypatching PowershellScript. J  Can you try this without powershell_out and see if you can get the same failure? I had no issues with the following fragment run via chef-apply â I just piped the output to a file in my recipe and after running chef-apply I verified the contents of the output file:  powershell_script 'filever' do  code <<-EOH   [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\\Program Files\\Internet Explorer\\iexplore.exe").FileVersion > ~\\fileversion.txt EOH  Chef-apply returned successfully when running a file with those contents and produced the following results:   11.00.9600.16384 (winblue_rtm.130821-1623)  Thanks Iain, Iâm definitely curious as to whatâs causing this and if thereâs something we can do to prevent it.  -Adam  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.