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, #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
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/facter/custom_facts/util/parser.rb', line 163 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}\"" output = Facter::Core::Execution.exec(shell_command) parse_executable_output(output) end |