Module: Chef::Mixin::PowershellOut

Instance Method Summary collapse

Methods included from WindowsArchitectureHelper

#assert_valid_windows_architecture!, #disable_wow64_file_redirection, #forced_32bit_override_required?, #is_i386_process_on_x86_64_windows?, #node_supports_windows_architecture?, #node_windows_architecture, #restore_wow64_file_redirection, #valid_windows_architecture?, #with_os_architecture, #wow64_architecture_override_required?, #wow64_directory

Methods included from ShellOut

apply_default_env, maybe_add_timeout, #shell_out, #shell_out!

Instance Method Details

#powershell_out(*command_args) ⇒ Mixlib::Shellout

Run a command under powershell with the same API as shell_out. The options hash is extended to take an “architecture” flag which can be set to :i386 or :x86_64 to force the windows architecture.

Parameters:

  • script (String)

    script to run

  • options (Hash)

    options hash

Returns:

  • (Mixlib::Shellout)

    mixlib-shellout object



33
34
35
36
37
38
# File 'lib/chef/mixin/powershell_out.rb', line 33

def powershell_out(*command_args)
  script = command_args.first
  options = command_args.last.is_a?(Hash) ? command_args.last : nil

  run_command_with_os_architecture(script, options)
end

#powershell_out!(*command_args) ⇒ Mixlib::Shellout

Run a command under powershell with the same API as shell_out! (raises exceptions on errors)

Parameters:

  • script (String)

    script to run

  • options (Hash)

    options hash

Returns:

  • (Mixlib::Shellout)

    mixlib-shellout object



46
47
48
49
50
# File 'lib/chef/mixin/powershell_out.rb', line 46

def powershell_out!(*command_args)
  cmd = powershell_out(*command_args)
  cmd.error!
  cmd
end