Class: Inspec::Resources::PowershellScript
- Defined in:
- lib/resources/powershell.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Cmd
Instance Method Summary collapse
-
#exist? ⇒ Boolean
we cannot determine if a command exists, because that does not work for scripts.
-
#initialize(script) ⇒ PowershellScript
constructor
A new instance of PowershellScript.
- #to_s ⇒ Object
Methods inherited from Cmd
#exit_status, #result, #stderr, #stdout
Constructor Details
#initialize(script) ⇒ PowershellScript
Returns a new instance of PowershellScript.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/resources/powershell.rb', line 21 def initialize(script) unless inspec.os.windows? return skip_resource 'The `script` resource is not supported on your OS yet.' end # encodes a script as base64 to run as powershell encodedCommand # this comes with performance issues: @see https://gist.github.com/fnichol/7b20596b950e65fb96f9 require 'winrm' script = WinRM::PowershellScript.new(script) cmd = "powershell -encodedCommand #{script.encoded}" super(cmd) end |
Instance Method Details
#exist? ⇒ Boolean
we cannot determine if a command exists, because that does not work for scripts
35 36 37 |
# File 'lib/resources/powershell.rb', line 35 def exist? nil end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/resources/powershell.rb', line 39 def to_s 'Powershell' end |