- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add the user to the local Administrators group using PowerShell?
To add the AD user or the local user to the local Administrators group using PowerShell, we need to use the Add-LocalGroupMember command.
To add the local user to the local Administrators group,
Add-LocalGroupMember -Group Administrators -Member TestUser -Verbose
The above command will add TestUser to the local Administrators group. You can provide any local group name there and any local user name instead of TestUser
You can also add the Active Directory domain user to the Local Administrators group by providing the domain name if the computer is in the same domain.
For example, we will add the Beta user from the AutomationLab domain as shown below.
Add-LocalGroupMember -Group Administrators -Member AutomationLab\Beta
You can provide the multiple members separated by comma (,) but only one local group is supported.
Add-LocalGroupMember -Group Administrators -Member TestUser, Testuser2 -Verbose
To add the local user or the AD user to the remote computer, use Invoke-Command.
Invoke-Command -ComputerName Computer1, Computer2 -ScriptBlock{ Add-LocalGroupMember -Group Administrators -Member TestUser1, TestUser2 }
- Related Articles
- How to get the local Administrators group members using PowerShell?
- How to change the local user account password using PowerShell?
- How to set the local user account settings using PowerShell?
- How to find the locked local user accounts using PowerShell?
- How to get the disabled local user accounts using PowerShell?
- How to remove a member from the local group using PowerShell?
- How to delete the local group from the windows system using PowerShell?
- How to create a new local group using PowerShell?
- How to create a new local user in windows using PowerShell?
- How to enable or disable local user on Windows OS using PowerShell?
- How to add a user to the group on linux
- How to add users and groups to the local groups on Windows System using PowerShell?
- How to change the local disk name using PowerShell?
- How to get the list of local groups using PowerShell?
- How to delete the Azure Resource Group using PowerShell?
