List members of a Windows group using command line

19

6

I would like to get a list of "normal" users in the Windows command line. By normal, I mean the users that appear when logging on to the computer. Thus, disabled accounts, accounts like System, and others that an average PC users would never log into, would not be in this list. I also need to know whether the users returned were admins or standard users. Any ideas?

D. Strout

Posted 2011-10-09T20:51:55.127

Reputation: 461

Should the list include "Power Users"? Guests? Standard users that have been granted Admin-equivalent privileges? The distinction is not as strict as you may think. – user1686 – 2011-10-10T12:02:57.423

I guess I pretty much want enabled standard users. In the scenario I need this for, the users are very unlikely to have created a bunch of accounts with weird privileges – D. Strout – 2011-10-10T13:22:16.637

Answers

33

To list users, use the net user command:

net user

You output get something like this:

User accounts for \\LOCALHOST

-------------------------------------------------------------------------------
joeuser          administrator                   guest
The command completed successfully.

If you need a list of users in a specific group, the use net localgroup:

net localgroup Users

You output get something like this:

Alias name     Users
Comment        Users are prevented from making accidental or intentional system-wide changes and can run most applications

Members

-------------------------------------------------------------------------------
NT AUTHORITY\Authenticated Users
NT AUTHORITY\INTERACTIVE
The command completed successfully.

This is for local system users, not domain accounts. If you want to know the membership of the Administrators group, you would just supply that as a parameter: net localgroup Administrators.

treehead

Posted 2011-10-09T20:51:55.127

Reputation: 526

Beware that net user may not list all user accounts; at least on a customer machine I'm currently working on, net user lists only 2 of the 4 existing local accounts. Haven't figured out why yet. – Martin von Wittich – 2016-11-15T12:46:52.023

Investigate the net command, it can do all kinds of things. This also works on servers. – mauvedeity – 2011-11-03T19:54:59.533

11

WMIC USERACCOUNT LIST BRIEF is another way to list the users in Windows. I'm not sure of the differences between net and WMIC. You can find more information about WMIC at http://ss64.com/nt/wmic.html

This is what WMIC USERACCOUNT LIST BRIEF returns on my machine:

C:\Users\ehtesh\AppData\Local>WMIC USERACCOUNT LIST BRIEF
AccountType  Caption                  Domain    FullName        Name            SID
512          wordless\Administrator   wordless                  Administrator   S-1-5-21-3098939154-701116006-2681273294-500
512          wordless\ehtesh          wordless                  ehtesh          S-1-5-21-3098939154-701116006-2681273294-1001
512          wordless\Guest           wordless                  Guest           S-1-5-21-3098939154-701116006-2681273294-501
512          wordless\HomeGroupUser$  wordless  HomeGroupUser$  HomeGroupUser$  S-1-5-21-3098939154-701116006-2681273294-1002

For more detailed information, you can call WMIC USERACCOUNT LIST FULL.

WMIC has information on a lot more about the system than just useraccounts. One example is Windows XP/Vista/7 Check Battery Charge from CMD?.

Ehtesh Choudhury

Posted 2011-10-09T20:51:55.127

Reputation: 1 330

3NET USER will only list user accounts & set passwords. WMIC will list all visible accounts, show type of account, and can also allow managing those accounts in many ways. NET is fast & simple, but very limited. WMIC is a very powerful tool that is worth learning in detail. – Debra – 2013-10-04T23:32:33.223

-1

use below command to get local admin users wmic -U domain/user //ip "SELECT * FROM Win32_GroupUser"| awk -F'"' '{print $4 " : " $8}'|grep -i Administrators|awk -F':' '{print $2}'

vivek singh

Posted 2011-10-09T20:51:55.127

Reputation: 1