Class: WinRM::PowershellScript
- Inherits:
-
Object
- Object
- WinRM::PowershellScript
- Defined in:
- lib/winrm/helpers/powershell_script.rb
Overview
Wraps a PowerShell script to make it easy to Base64 encode for transport
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#encoded ⇒ String
Encodes the script so that it can be passed to the PowerShell –EncodedCommand argument.
-
#initialize(script) ⇒ PowershellScript
constructor
Creates a new PowershellScript object which can be used to encode PS scripts for safe transport over WinRM.
Constructor Details
#initialize(script) ⇒ PowershellScript
Creates a new PowershellScript object which can be used to encode PS scripts for safe transport over WinRM.
25 26 27 |
# File 'lib/winrm/helpers/powershell_script.rb', line 25 def initialize(script) @text = script end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
20 21 22 |
# File 'lib/winrm/helpers/powershell_script.rb', line 20 def text @text end |
Instance Method Details
#encoded ⇒ String
Encodes the script so that it can be passed to the PowerShell –EncodedCommand argument.
32 33 34 35 |
# File 'lib/winrm/helpers/powershell_script.rb', line 32 def encoded encoded_script = text.encode('UTF-16LE', 'UTF-8') Base64.strict_encode64(encoded_script) end |