Here is a simple Powershell script that I created, if you need to add domain computer accounts, users or groups to the local administrator group.
The script should be run locally on the computer on which you want the accounts to be added to the local administrator group.

 #Add Computers/Users/Groups to the local administrator group
 # Version 1.0
 #Date created: 2013-08-29
 #Created by: Daniel Classon

 $computername= "$env:computername"

function AddToGroup($number)
     $group.add("WinNT://"+$domain+"/"+$number )

#Add these domain users/groups to the local administrator group
 AddToGroup "<group>"
 AddToGroup "<group>"
#Add these domain computer accounts to the local administrator group. Computer accounts always end with $.
 AddToGroup "<computer account>$"




  1. one of the things that irritates me to no end when i look at scripts online is the lack of documentation in them.
    for folks that are trying to learn it is nice to know what each function or call is doing within the script.
    It’s also nice when you enclose the usage information within the script documentation, ie what version of Ps you are writing to, etc. that way people hunting for code snippets dont have to read 3/4 of the way down the page only t9o find that this is applicable to windows server 2012 that runs powershell 3.0 or higher..


Please enter your comment!
Please enter your name here