• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 320
  • Last Modified:

Add Active Directory group to local Win2K Group

I need to add an AD group to the Adiministrators group on many Win2k PCs. It works fine on a manual add but... How can I script this?
0
tjipson
Asked:
tjipson
  • 2
1 Solution
 
oBdACommented:
From the command line (or a batch) when logged on to the machine:
net localgroup Administrators "YourDomain\YourADGroup" /add

If you have the W2k Resource Kit, you can use cusrmgr remotely (if you have a list of machines, this can be scripted to process the list):
cusrmgr -alg -m \\RemoteMachine -u "YourDomain\YourADGroup"
0
 
SaintBACommented:
Here you are !
First, create a txt file with this format (don't forget the commas!):

computername01,
computername02,
computername03,
computernamexx,

Save it as "whatever.cvs"

Then...copy/paste the folowing into a .txt file and rename it to "whatever.vbs"
Be sure to run it in a windows  2k machine (and above), and to be logged with an account part of the domain admin group, and to have both cvs & vbs file in the same folder. After you save it as a .vbs file...just double-click on it :-)

'Here starts the Script
Dim oFSO, strGroup
strGroup = "yourdomain\yourgroup"
sFlag=0

Const ForReading = 1
Set oFSO = CreateObject("scripting.filesystemobject")
Set oTF = oFSO.OpenTextFile("whatever.csv",ForReading,True)

Do While oTF.AtEndOfStream <> True
      sLine = oTF.ReadLine
      aLine = split(sline, ",",-1,1)
      strComputer = aline(0)
      Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
     On Error Resume Next
      Set objUser = GetObject("WinNT://" & strGroup)
      objGroup.Add(objUser.ADsPath)
      MsgBox "Group Added in: " & strComputer
Loop
0
 
oBdACommented:
Stupid me. Forgot to specify the local group:
cusrmgr -alg Administrators -m \\RemoteMachine -u "YourDomain\YourADGroup"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now