Solved

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

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
copy-item script help 15 66
exchange, scripts 30 77
Copy Description data to info field for multiple active directory accounts 7 57
Powershell Script to list Permissions 7 34
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
A brief introduction to what I consider to be the best editor for PowerShell.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

911 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

21 Experts available now in Live!

Get 1:1 Help Now