Using a Script to Add a Domain User to a Local Group

by Chris Sanders [Published on 31 Aug. 2006 / Last Updated on 31 Aug. 2006]

There are sometimes situations when you need to be able to script the process of adding a domain user to a local group on a machine. Here is a script that will do just that.

I ran into a scenario recently where I needed to add a domain group to the local administrators group of a large collection of workstations in my network. Rather than go around to all 500 of these machines individually I found a very useful little VBS script for getting this done.

option Explicit

Dim objGroup
Dim strComputer

On Error Resume Next

‘Variables you will want to change
strComputer = “.” ‘Computer is Local

‘Create Objects
Set objGroup = GetObject(”WinNT://” & strComputer & “/Administrators,group”)

‘Modify group memberships
Set objGroup = Nothing

Replace your variables, push this out via GPO, and voila! Enjoy!


Chris Sanders is the network administrator for one of the largest public school systems in the state of Kentucky. Chris's specialties include general network administration, windows server 2003, wireless networking, and security. You can view Chris' personal website at

See Also

The Author — Chris Sanders

Chris Sanders is a network security analyst for EWA Government Systems Inc. Chris is the author of the book Practical Packet Analysis as well as several technical articles. His personal website at contains a great deal of information, articles, and guides related to network administration, network security, packet analysis, and general information technology.

Featured Links