self.logged_on_user_query

in itchef/cookbooks/cpe_helpers/libraries/cpe_helpers.rb [210:238]


    def self.logged_on_user_query
      query = shell_out('%WINDIR%\system32\query.exe user', :timeout => 60)
      output = query.stdout.split("\n")

      if output.size <= 1
        Chef::Log.debug('no one is currently logged in')
        return nil
      end

      
      active_user = nil
      output.drop(1).each do |line|
        row = line.split
        
        
        
        if row[3].strip.downcase == 'active'
          active_user = row[0].tr('>', '').strip
          break
        end
      end
      active_user
    rescue Mixlib::ShellOut::CommandTimeout
      Chef::Log.warn('command timeout while looking up user')
    rescue StandardError => e
      Chef::Log.warn(e.to_s)
      nil
    end