Solved

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

Posted on 2014-01-29
3
1,034 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 39

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete Msol groups from csv file 2 36
DFS-R questions 4 22
Copy items in a folder structure then put them back. 4 20
Powershell Script Help 3 21
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Synchronize a new Active Directory domain with an existing Office 365 tenant
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

786 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