≡ Menu

List of user groups command line

On Windows OS we can find the list of local user groups created on a system from Contorl Panel -> User Accounts. This information can be obtained from command line also using net command.  Syntax is shown below.

net localgroup

Example: Running this command shows the following local groups on my system.

C:\>net localgroup
Aliases for \\techblogger-pc
----------------------------------------------------------------------------
*Administrators
*Backup Operators
*Debugger Users
*Guests
*Network Configuration Operators
*Power Users
*Remote Desktop Users
*Replicator
*Users
The command completed successfully.

How to list the users in a local group?

Use the below command to know the list of members of a group from command line.

net localgroup groupName

For example to get the list of all remote desktop users on a system we can run the below command.

net localgroup "Remote Desktop users"

How to find the list of all groups a user is member of?
You can run the below command to list the groups a user is member of.  This command prints the details of the given user account. You can find the group membership information in the last two line of this command output.

net user userName

Example:

H:\>net user John
User name                   John
Full Name
Comment
User's comment
Country code                 000 (System Default)
Account active               Yes
Account expires              Never
Password last set            12/2/2010 11:00 PM 
Password expires             4/1/2011 11:00 PM 
Password changeable          12/2/2010 11:00 PM 
Password required            Yes 
User may change password     Yes 
Workstations allowed         All 
Logon script 
User profile 
Home directory 
Last logon 
Logon hours allowed          All 
Local Group Memberships      *Debugger Users       *Users 
Global Group memberships     *None

Related Posts:
Add user to group from windows command line
Remove user from group using windows command prompt

11 comments… add one
  • Kennedy

    Useful references, however “net use username” should be changed to “net user username”

    • admin

      Thank you Kennedy. Corrected the command.

  • SD

    Please get me a command which will display all local users as: LOGIN, FULL NAME, DESCRIPTION, GROUP etc..

  • Doug

    I’d just like to express my frustration with this API. As you can see in these examples, thet net API localgroups functionality will happily list all members of a group. However the net user code completely ignores system accounts, as does most of the rest of what Windows makes available. Internally they are organized as a subclass of Win32_Account but not Win32_UserAccount. So it’s possible to retrieve a bunch of useless information from the Windows API. This happens with LookupAccountSid as well. If you give it an SID like S-1-5-20, it will give you an answer. But the answer it gives you can’t be used as input for anything else, which is obnoxious.

    • Werezwolf

      You can query if users exist by doing

      SET /P query_user=What user do i look for?
      ::Take out /domain if you want to look on the local computer
      Net User %query_user% /domain
      if NOT %errorlevel% == 0 goto s_error_1
      if %errorlevel% == 0 goto s_success_1

  • Bill

    “net user /domain username” lists only the groups to which the username is a direct member. It can’t show nested groups. I was doing a quick check to see if a username was a member of a group:

    net user /domain username | find “Group Name”

    That fails since the user is not directly a member of “Group Name”. In reality, they are a member, as they’re a member of a nested group.

    Any idea of a command line that will expand groups to look for a particular member? I’ve used the “dsquery” and “dsget” commands, but they are only present if the AD tools are installed.

  • Bloggeur

    Very useful thanks, didn’t worked for me the first time.

    The command is not case sensitive.

    For example “NET USER /DOMAIN MYDOMAIN/MyUser” Didn’t worked.

    But “NET USER /DOMAIN MyUser” works fine!
    So not necessary to put explicitly the domain.

    By the way it means also you can’t query another domain than the main one you are logged on to ?

  • AV

    Is there any option where we can get the multiple user’s output in excel for local computer and remote computer
    net user userName

    • Kunal

      Simply redirect the output to the excel (better to a .csv) file.
      FOR LOCAL
      net user USERNAME | find /I “FULL NAME”> d:\username.csv

      FOR DOMAIN
      net user /domain USERNAME | find /I “FULL NAME”> d:\username.csv

  • Les Coover

    (1) Could someone show me how to join a users group that deals with Windows 10 command line?
    (2) In the command Prompt I have:
    Microsoft Windows [Version 10.0.18363.1016]
    (c) 2019 Microsoft Corporation. All rights reserved.
    C:\Users\Coover> d:
    D:\> :: move program execution for C drive to D drive

    In the last line, is there a way to change the word “for” to “from” without typing the line again?

  • Brett Morgan

    I can’t find Contorl Panel

Leave a Comment