Methods

Class/Module Index [+]

Quicksearch

Facter::Util::Parser::PowershellParser

Executes and parses the key value output of Powershell scripts

Public Instance Methods

parse_results() click to toggle source

Returns a hash of facts from powershell output

# File lib/facter/util/parser.rb, line 141
def parse_results
  powershell =
    if File.exists?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe")
      "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
    elsif File.exists?("#{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)
  KeyValuePairOutputFormat.parse(output)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.