Solved

Add Active Directory group to local Win2K Group

Posted on 2004-09-16
3
315 Views
Last Modified: 2010-03-18
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
Comment
Question by:tjipson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Expert Comment

by:oBdA
ID: 12082789
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
 
LVL 2

Accepted Solution

by:
SaintBA earned 500 total points
ID: 12088806
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
 
LVL 85

Expert Comment

by:oBdA
ID: 12091469
Stupid me. Forgot to specify the local group:
cusrmgr -alg Administrators -m \\RemoteMachine -u "YourDomain\YourADGroup"
0

Featured Post

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Downtime reduced, data recovered by utilizing an Experts Exchange Business Account Challenge The United States Marine Corps employs more than 200,000 active-duty Marines with operations in four continents, all requiring complex networking system…
An article on effective troubleshooting
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question