Method: Windows::User#user_list_using_powershell

Defined in:
lib/beaker/host/windows/user.rb

#user_list_using_powershellObject

using powershell commands as wmic is deprecated in windows 2025



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/beaker/host/windows/user.rb', line 18

def user_list_using_powershell
  execute('cmd /c echo "" | powershell.exe "Get-LocalUser | Select-Object -ExpandProperty Name"') do |result|
    users = []
    result.stdout.each_line do |line|
      users << line.strip or next
    end

    yield result if block_given?

    users
  end
end