Class: LegacyFacter::Util::Parser::PowershellParser
- Defined in:
- lib/facter/custom_facts/util/parser.rb
Overview
Executes and parses the key value output of Powershell scripts
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#parse_results ⇒ Object
Returns a hash of facts from powershell output.
Methods inherited from Base
#content, #initialize, #log_stderr, #parse_executable_output, #results
Constructor Details
This class inherits a constructor from LegacyFacter::Util::Parser::Base
Instance Method Details
#parse_results ⇒ Object
Returns a hash of facts from powershell output
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/facter/custom_facts/util/parser.rb', line 190 def parse_results powershell = if File.readable?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe") "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" elsif File.readable?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe") "#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" else 'powershell.exe' end shell_command = "\"#{powershell}\" -NoProfile -NonInteractive -NoLogo -ExecutionPolicy Bypass -File \"#{filename}\"" stdout, stderr = Facter::Core::Execution.execute_command(shell_command) log_stderr(stderr, shell_command, filename) parse_executable_output(stdout) end |