To add a user or group to the local administrator group using PowerShell, use the PowerShell command `Add-LocalGroupMember
`.
Here is the PowerShell command to add groups or users to the local admin group.
Add-LocalGroupMember -Group "<group name>" -Member "<user/groups>"
The Add-LocalGroupMember
command uses the Group
parameter to specify the “Administrators” group and the Member
parameter to specify the users or groups that you want to add to the group.
In this article, we will discuss how to add a user to the local admin group, add multiple members to the admin group, and add domain users to the admin group using the PowerShell command.
How to Add User to Local Admin Group using PowerShell
Use the Add-LocalGroupMember command to add a user to the local admin group, and run the following PowerShell command.
Add-LocalGroupMember -Group "Administrators" -Member "Gary"
In the above PowerShell script, the Add-LocalGroupMember
cmdlet uses the Group
parameter to specify the local admin group “Administrators” and the Member
parameter to specify the user name “Gary” that you want to add to the local admin group.
The output of the above PowerShell script adds a user to the local admin group.
How to Add Multiple Users to Local Administrator Group Using PowerShell
To add multiple users to the local administrator group using PowerShell, use the Add-LocalGroupMember
command with the Member
parameter to specify the multiple users separated by a comma.
Add-LocalGroupMember -Group "Administrators" -Member "TestUser1","TestUser2"
The above PowerShell script adds multiple users to the local administrator group.
How to Add Domain User to Local Admin Group Using PowerShell
You can add the domain user to the local admin group using the PowerShell Add-LocalGroupMember
command.
Add-LocalGroupMember -Group "Administrators" -Member "ShellPro\Adam
In the above PowerShell script, add domain user “ShellPro\Adam” to the “Administrators” group.
Conclusion
I hope the above article on how to add users to the local admin group using the PowerShell Add-LocalGroupMember
command is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.