PowerShell Add User to Administrators Group

Powershell add users to administrators group

The user must have administrative privileges to use the following commands. Also, the user must be created on the computer to add to the administrators group.

Using *-LocalGroupMember Cmdlet

Using PowerShell, we can use the *-LocalGroupMember command to add/check/remove one or multiple users to the administrators group. Here, * can be Add, Get, or Remove based on what we want to achieve. Let’s learn each of them below.

Use the Add-LocalGroupMember command to add a user to the administrators group using PowerShell.

The above command will not show any output or error if everything is in the right place.

Use the Get-LocalGroupMember command to check a user is added to the administrators group using PowerShell.

Use the Remove-LocalGroupMember command to remove a user from the administrators group using PowerShell.

This command will not display any output or message but will generate an error if you have done something incorrectly.

Use the Add-LocalGroupMember command to add multiple users to the administrators group using PowerShell.

If everything is correct, the above command will not show any output, warning or error.

Use the Get-LocalGroupMember command to check if multiple users are added to the administrators group using PowerShell.

Use the Remove-LocalGroupMember command to remove multiple users from the administrators group using PowerShell.

This command will not show any output or message but will display an error if you have done something wrong.

In the above examples, the commands are composed of different options whose brief description is given below:

  • Add-LocalGroupMember cmdlet was used to add one or multiple users to the local group on Windows PC.
  • Get-LocalGroupMember cmdlet was used to retrieve one or multiple users from the local group on Windows PC.
  • Remove-LocalGroupMember was used to remove one or more users from the local group on a Windows computer.
  • -Group parameter was used to mention the local group’s name. In the above examples, the group name is "Administrators".
  • -Member parameter was used to specify the user’s name that will be added to or removed from the local group.
  • "Administrators" is the name of the local group.
  • "Tony" & "Adam" are the placeholders for the username variable.

Using net localgroup Command

Using PowerShell, we can use the net localgroup command to add/check/remove one or multiple users to the administrators group. Let’s learn each of them below.

Use the net localgroup command to add a user to the administrators group using PowerShell.

Use the net localgroup command to check if a user is added to the administrators group using PowerShell.

Use the net localgroup command to remove a user from the administrators group using PowerShell.

Use the net localgroup command to add multiple users to the administrators group using PowerShell.

Use the net localgroup command to check if multiple users are added to the administrators group using PowerShell.

Use the net localgroup command to remove multiple users from the administrators group using PowerShell.

In the above examples, the commands are comprised of different options whose brief description is given below.

  • net is the command utility we use for different network-related tasks in Windows operating systems.
  • localgroup is the sub-command we used to manage local groups on the Windows PC.
  • administrators is the local group’s name, which we targeted in the above commands. It is the built-in administrators group in Windows PC.
  • /add option was specified to add the given user(s).
  • /delete option was used to delete the given user(s).
  • Tony & Adam are the values for the username placeholder to be added/removed from the administrators group. The usernames will be separated by a comma if there are two or more usernames.

Use the net localgroup administrators | findstr /c:"Tony" command if you are interested in getting that one username only for which you want to check if it is added to the administrators group or not. You will get the specified username if it is added; otherwise, not. Don’t forget to replace "Tony" with your username.

That’s all about PowerShell add user to administrators group.

Was this post helpful?

Leave a Reply

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