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
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/facter/custom_facts/util/parser.rb', line 176 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 |