Solved

Add a computer account in Active Directory to the local administrator group using PowerShell

Posted on 2014-01-29
3
1,066 Views
Last Modified: 2014-01-29
Hello. I have a PowerShell script that runs locally on a machine performing several different actions. One of the actions is to add a specific computer account in Active Directory. For example, I have a computer called Desktop that is in the Lab domain. I would like to add a computer account called Server to the local administrator group on Desktop.

I have tried several different approaches without success. Could anyone offer advice?
0
Comment
Question by:Lorrec
  • 2
3 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39819639
You should be able to run the following from an elevated prompt on Desktop, where "Server$" is the computer account you wish to add.
$group = [ADSI]"WinNT://./Administrators,group"  
$group.Add("WinNT://Server$,user")

Open in new window

0
 

Author Comment

by:Lorrec
ID: 39819760
Exactly what I needed. Thank you.
0
 

Author Closing Comment

by:Lorrec
ID: 39819761
Thank you for the quick response.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question