I would like to know if there is a way to return a variable value from a powershell script defined in powershell_script
resource?
My powershell
resource looks like following:
powershell_script "Test Script" do
code <<-EOH
Write-Host "Hello World!"
return "test"
EOH
end
I would like to use the returned value test
from the script to use in other resources based on if conditions.
Thanks
Ohai!
I think you actually want to use the PowershellOut
Mixin found here in the Powershell cookbook.
Chef resources rarely return values, but that's what heavy-weight resources are for!
If you have the powershell cookbook, you can do this:
include Chef::Mixin::PowershellOut
cmd = powershell_out!('command')
cmd.stdout #=> ...
cmd.stderr #=> ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With