Class: Chef::Provider::PowershellScript

Inherits:
WindowsScript show all
Defined in:
lib/chef/provider/powershell_script.rb

Constant Summary

Constants included from Mixin::ShellOut

Mixin::ShellOut::DEPRECATED_OPTIONS

Instance Attribute Summary

Attributes inherited from Chef::Provider

#action, #current_resource, #new_resource, #run_context

Instance Method Summary collapse

Methods inherited from WindowsScript

#action_run, #script_file

Methods included from Mixin::WindowsArchitectureHelper

#assert_valid_windows_architecture!, #disable_wow64_file_redirection, #is_i386_windows_process?, #node_supports_windows_architecture?, #node_windows_architecture, #restore_wow64_file_redirection, #valid_windows_architecture?, #wow64_architecture_override_required?

Methods inherited from Script

#action_run, #interpreter, #script_file, #set_owner_and_group, #unlink_script_file

Methods inherited from Execute

#action_run, #load_current_resource, #whyrun_supported?

Methods included from Mixin::ShellOut

#run_command_compatible_options, #shell_out, #shell_out!

Methods inherited from Chef::Provider

#action_nothing, #cleanup_after_converge, #converge_by, #cookbook_name, #define_resource_requirements, #events, #load_current_resource, #node, #process_resource_requirements, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, #whyrun_mode?, #whyrun_supported?

Methods included from DSL::Recipe

#method_missing

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Constructor Details

#initialize(new_resource, run_context) ⇒ PowershellScript

Returns a new instance of PowershellScript.



45
46
47
48
# File 'lib/chef/provider/powershell_script.rb', line 45

def initialize (new_resource, run_context)
  super(new_resource, run_context, '.ps1')
  NormalizeScriptExitStatus(new_resource.code)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::DSL::Recipe

Instance Method Details

#flagsObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/chef/provider/powershell_script.rb', line 50

def flags
  default_flags = [
    "-NoLogo",
    "-NonInteractive",
    "-NoProfile",
    "-ExecutionPolicy RemoteSigned",
    # Powershell will hang if STDIN is redirected
    # http://connect.microsoft.com/PowerShell/feedback/details/572313/powershell-exe-can-hang-if-stdin-is-redirected
    "-InputFormat None",
    # Must use -File rather than -Command to launch the script
    # file created by the base class that contains the script
    # code -- otherwise, powershell.exe does not propagate the
    # error status of a failed Windows process that ran at the
    # end of the script, it gets changed to '1'.
    "-File"
  ]

  interpreter_flags = default_flags.join(' ')

  if ! (@new_resource.flags.nil?)
    interpreter_flags = [@new_resource.flags, interpreter_flags].join(' ')
  end

  interpreter_flags
end