Guest User

Untitled

a guest
Oct 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. def run_powershell(powershell_command)
  2. puts %Q-Executing powershell #{powershell_command}-
  3. output = system("powershell.exe #{powershell_command}")
  4. puts "Executed powershell output #{output}"
  5. end
  6.  
  7. success = system("powershell.exe #{powershell_command}")
  8. if success then
  9. ...
  10. end
  11.  
  12. output = `powershell.exe #{powershell_command}`
  13. success = $?.exitstatus == 0
  14.  
  15. output = IO::popen(["powershell.exe", powershell_command]) {|io| io.read}
  16. success = $?.exitstatus == 0
  17.  
  18. def powershell_output_true?()
  19. ps_command = "(1+1) -eq 2"
  20. cmd_str = "powershell -Command " " + ps_command + " " "
  21. cmd = shell_out(cmd_str, { :returns => [0] })
  22. if(cmd.stdout =~ /true/i)
  23. Chef::Log.debug "PowerShell output is true"
  24. return true
  25. else
  26. Chef::Log.debug "PowerShell output is false"
  27. return false
  28. end
  29. end
Add Comment
Please, Sign In to add comment