Script to add an Active Directory Domain User or Group to a Windows Local Group


This Technet Hey Scripting Guy column describes how to add a Domain Group to a Local Windows Group:

strComputer = “atl-ws-001”

Set objLocalGroup = GetObject(“WinNT://” & strComputer & “/TestGroup”)
Set objADGroup = GetObject(“WinNT://Fabrikam/Finance”)

objLocalGroup.Add(objADGroup.ADsPath)

where:

  • atl-ws-001 is the name of the local computer you wish to add the domain group to
  • TestGroup is the name of the local group
  • Finance is the name of the Fabrikam domain group

Similarly, this Hey Scripting Guy column provides a script for adding a domain user to the local administrators group:

strComputer = “atl-ws-01”
Set objGroup = GetObject(“WinNT://” & strComputer & “/Administrators”)
Set objUser = GetObject(“WinNT://fabrikam/kenmyer”)
objGroup.Add(objUser.ADsPath)

where:

  • atl-ws-001 is the name of the local computer you wish to add the domain user to
  • Administrators is the name of the local Administrators group
  • KenMeyer is the name of the Fabrikam domain user

Save your script with a .vbs file extension, i.e. adduser.vbs. From a command prompt, run cscript adduser.vbs to execute the script.

One Response to “Script to add an Active Directory Domain User or Group to a Windows Local Group”

  1. Tilahun Says:

    This script works for a single computer. But what need is in OU there is a list of computer I need to add a user on all this computer in one shoot. Caan you help me to do this.

    Thank you,


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: