Add User to Group from Command line [CMD]

By | March 18, 2022

Users can manage their groups with command-line tools provided by Windows. We will cover how to add a user to a group using a command net localgroup from the command prompt in this post. Let’s see – how to cmd add a user.

How to add a user to a group –

Add User to Group from Command line

To get started, follow these steps:

Step-1: Open a greater command prompt.
Step-2: The following command should be run.

net localgroup group_name UserLoginName /add

You can run the below command to add the user (John) to the administrator’s group for example.

net localgroup administrators John /add

The following are some more examples:

You can add a local users group to a domain user by following these steps:

net localgroup users domainname\username /add

During a network connection, you should run this command. Alternatively, an error will appear.

H:\>net localgroup users domain\user /add
System error 1789 has occurred.
The trust relationship between this workstation and the primary domain failed.

The following steps will add a domain user to the local administrator group:

net localgroup administrators domainname\username /add

A remote desktop user can be added to the group by following these steps:

net localgroup "Remote Desktop Users" UserLoginName  /add

An individual may be added to the group of debugger users by following these steps:

net localgroup "Debugger users" UserLoginName /add

The following steps should be taken to Power Users group can be expanded by adding users:

net localgroup "Power users" UserLoginName /add

There is a command that can be used with all of Windows OS, including Windows 7. However, you still take an error like the following even if you are logged in as an administrator.

C:\> net localgroup administrators techblogger /add
System error 5 has occurred.
Access is denied.

It is possible to fix this situation by running as an administrator.
Using an elevated administrator account is the solution.
An elevated command prompt runs net localgroup as follows:

C:\>net localgroup administrators techblogger /add
The command completed successfully.

This command can be used to find out who belongs to a specific group.

net localgroup group_name

As an example, The following needs to be run to view all users who belong to the administrator’s group.

net localgroup administrators

You may also like: Kill Process from Command line [CMD]

Leave a Reply

Your email address will not be published. Required fields are marked *