class WinRM::PowershellScript

Wraps a PowerShell script to make it easy to Base64 encode for transport

Attributes

text[R]

Public Class Methods

new(script) click to toggle source

Creates a new PowershellScript object which can be used to encode PS scripts for safe transport over WinRM. @param [String] The PS script text content

# File lib/winrm/helpers/powershell_script.rb, line 24
def initialize(script)
  @text = script
end

Public Instance Methods

encoded() click to toggle source

Encodes the script so that it can be passed to the PowerShell –EncodedCommand argument. @return [String] The UTF-16LE base64 encoded script

# File lib/winrm/helpers/powershell_script.rb, line 31
def encoded
  encoded_script = text.encode('UTF-16LE', 'UTF-8')
  Base64.strict_encode64(encoded_script)
end