- 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 }
To Continue Learning Please Login
Login with Google