Class: Chef_PowerShell::PowerShell
- Inherits:
-
Object
- Object
- Chef_PowerShell::PowerShell
- Defined in:
- lib/chef-powershell/powershell.rb
Direct Known Subclasses
Defined Under Namespace
Modules: PowerMod
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
- #error! ⇒ Object
-
#error? ⇒ Boolean
Was there an error running the command.
-
#initialize(script, timeout: -1)) ⇒ Object
constructor
Run a command under PowerShell via FFI This implementation requires the managed dll and native wrapper to be in the library search path on Windows (i.e. c:windowssystem32 or in the same location as ruby.exe).
Constructor Details
#initialize(script, timeout: -1)) ⇒ Object
Run a command under PowerShell via FFI This implementation requires the managed dll and native wrapper to be in the library search path on Windows (i.e. c:windowssystem32 or in the same location as ruby.exe).
Requires: .NET Framework 4.0 or higher on the target machine.
40 41 42 43 44 45 46 47 48 |
# File 'lib/chef-powershell/powershell.rb', line 40 def initialize(script, timeout: -1) # This Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim # Every merge into that repo triggers a Habitat build and promotion. Running # the rake :update_chef_exec_dll task in this (chef/chef) repo will pull down # the built packages and copy the binaries to chef-powershell/bin/ruby_bin_folder. Bundle install # ensures that the correct architecture binaries are installed into the path. @powershell_dll = Gem.loaded_specs["chef-powershell"].full_gem_path + "/bin/ruby_bin_folder/#{ENV["PROCESSOR_ARCHITECTURE"]}/Chef.PowerShell.Wrapper.dll" exec(script, timeout: timeout) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
28 29 30 |
# File 'lib/chef-powershell/powershell.rb', line 28 def errors @errors end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
27 28 29 |
# File 'lib/chef-powershell/powershell.rb', line 27 def result @result end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
29 30 31 |
# File 'lib/chef-powershell/powershell.rb', line 29 def verbose @verbose end |
Instance Method Details
#error! ⇒ Object
64 65 66 |
# File 'lib/chef-powershell/powershell.rb', line 64 def error! raise Chef_PowerShell::PowerShellExceptions::PowerShellCommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error? end |
#error? ⇒ Boolean
Was there an error running the command
55 56 57 58 59 |
# File 'lib/chef-powershell/powershell.rb', line 55 def error? return true if errors.count > 0 false end |