Config Server Firewall

The Net Localgroup Command

We use the command net localgroup to display and manage groups from the command prompt (CMD or PowerShell) in the Windows operating system.

Administrators can perform the following tasks using the net localgroup command:

Command options

GroupNameName of the group to be added or modified. If the group name includes spaces, enclose it in quotation marks.
/domainUse this command switch to execute the net localgroup command on the Active Directory domain controller rather than on the local computer.
/addUse this option to add new groups to the Windows system or add users to existing groups.
/deleteUse this option to delete groups or remove members from groups.
/comment:"text"Adds a description to a Windows group.

Notes

When operating in an Active Directory domain environment, always use the /domain command switch.

There is another Windows command, the net group, which has the same syntax as the net localgroup. The net group command creates global groups; the net localgroup command creates local groups.

In the CMD, you can get help by running the net help localgroup command.

Next, we will learn more about the net localgroup command by looking at several examples.

Display Information on Existing Windows Groups

the net localgroup command

We can use the net localgroup command to list groups and view detailed information about a particular group.

To get a list of groups on the local computer, type net localgroup and press Enter:

net localgroup

To do the same thing on an Active Directory domain controller, use the /domain command switch:

net localgroup /domain

To get detailed information about a group, type net localgroup followed by the group name. For example, to view the Administrators group, you will run the following command:

net localgroup Administrators
net localgroup /domain Administrators

The command lists the users in the Administrators group.

net localgroup Administrators
Net Localgroup Administrators

Add/Delete Groups

To add a new local group, use the following syntax, where GroupName is the name of the new group:

net localgroup /add GroupName

For example, to create a group called sales, you will run the following command:

net localgroup /add sales

To remove a group from Windows, use the /delete option. For example, to remove an existing group called sales, you will run the following command:

net localgroup /delete sales

Add a description while creating the group:

net localgroup /add sales /comment:"This is Sales Group"

Add a description to the existing group:

net localgroup sales /comment:"Sales group"

Add (or Remove) User to the Groups

To add a user to a group, use the following syntax:

net localgroup /add GroupName UserName

The following command adds user user1 to the sales group:

net localgroup /add sales user1

You can add multiple users to a group at once:

net localgroup /add sales user1 user2

To remove a user from a group, use the /delete option:

net localgroup /delete sales user1
net localgroup /delete sales user1 user2

Examples

List all the local groups:

net localgroup

Add a new local group called sales:

net localgroup /add sales

Delete sales group:

net localgroup /delete sales

This command lists the users in the Remote Desktop Users group:

net localgroup "Remote Desktop Users"

The following command adds user user1 to the Remote Desktop Users group:

net localgroup /add "Remote Desktop Users" user1

The following command removes user1 from the Remote Desktop Users group:

net localgroup /delete "Remote Desktop Users" user1

What Next?

That brings the end to this tutorial. Next, you can learn the net user command, which is used to manage Windows users from the command prompt.