Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
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 …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now