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.
{ 1 comment… read it below or add one }
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,