class Chef::Resource::PowershellScript
Public Class Methods
get_default_attributes(opts)
click to toggle source
Allow callers evaluating guards to request default attribute values. This is needed to allow convert_boolean_return
to be true in guard context by default, and false by default otherwise. When this mode becomes the default for this resource, this method can be removed since guard context and recipe resource context will have the same behavior.
# File lib/chef/resource/powershell_script.rb, line 69 def self.get_default_attributes(opts) { convert_boolean_return: true } end
new(name, run_context = nil)
click to toggle source
Calls superclass method
Chef::Resource::WindowsScript::new
# File lib/chef/resource/powershell_script.rb, line 49 def initialize(name, run_context = nil) super(name, run_context, :powershell_script, "powershell.exe") @convert_boolean_return = false end
Public Instance Methods
convert_boolean_return(arg = nil)
click to toggle source
# File lib/chef/resource/powershell_script.rb, line 54 def convert_boolean_return(arg = nil) set_or_return( :convert_boolean_return, arg, kind_of: [ FalseClass, TrueClass ] ) end
default_flags()
click to toggle source
Options that will be passed to Windows PowerShell
command
# File lib/chef/resource/powershell_script.rb, line 74 def default_flags return "" if Chef::Platform.windows_nano_server? # Execution policy 'Bypass' is preferable since it doesn't require # user input confirmation for files such as PowerShell modules # downloaded from the Internet. However, 'Bypass' is not supported # prior to PowerShell 3.0, so the fallback is 'Unrestricted' execution_policy = Chef::Platform.supports_powershell_execution_bypass?(run_context.node) ? "Bypass" : "Unrestricted" [ "-NoLogo", "-NonInteractive", "-NoProfile", "-ExecutionPolicy #{execution_policy}", # 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", ].join(" ") end