Sha256: 9c29aa2076729b867672c9fcc1cd7ba25f5e44013492ef826d38153880cb1183
Contents?: true
Size: 841 Bytes
Versions: 52
Compression:
Stored size: 841 Bytes
Contents
module PSWindows::User include Beaker::CommandFactory def user_list(&block) execute('cmd /c echo "" | wmic useraccount where localaccount="true" get name /format:value') do |result| users = [] result.stdout.each_line do |line| users << (line.match(/^Name=(.+)/) or next)[1] end yield result if block_given? users end end def user_get(name, &block) execute("net user \"#{name}\"") do |result| fail_test "failed to get user #{name}" if result.exit_code != 0 yield result if block_given? result end end def user_present(name, &block) execute("net user /add \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block) end def user_absent(name, &block) execute("net user /delete \"#{name}\"", {:acceptable_exit_codes => [0,2]}, &block) end end
Version data entries
52 entries across 52 versions & 1 rubygems