Module: ChefPowerShell::ChefPowerShellModule::PowerShellExec
- Included in:
- ChefPowerShellModule
- Defined in:
- lib/chef-powershell/powershell_exec.rb
Instance Method Summary collapse
-
#powershell_exec(script, interpreter = :powershell, timeout: -1)) ⇒ Chef::PowerShell
Run a command under PowerShell via a managed (.NET) API.
-
#powershell_exec!(script, interpreter = :powershell, **options) ⇒ Object
The same as the #powershell_exec method except this will raise ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed if the command fails.
Instance Method Details
#powershell_exec(script, interpreter = :powershell, timeout: -1)) ⇒ Chef::PowerShell
Run a command under PowerShell via a managed (.NET) API.
Requires: .NET Framework 4.0 or higher on the target machine.
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/chef-powershell/powershell_exec.rb', line 113 def powershell_exec(script, interpreter = :powershell, timeout: -1) case interpreter when :powershell ChefPowerShell::PowerShell.new(script, timeout: timeout) when :pwsh ChefPowerShell::Pwsh.new(script, timeout: timeout) else raise ArgumentError, "Expected interpreter of :powershell or :pwsh" end end |
#powershell_exec!(script, interpreter = :powershell, **options) ⇒ Object
The same as the #powershell_exec method except this will raise ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed if the command fails
126 127 128 129 130 |
# File 'lib/chef-powershell/powershell_exec.rb', line 126 def powershell_exec!(script, interpreter = :powershell, **) cmd = powershell_exec(script, interpreter, **) cmd.error! cmd end |