Solved

Add Active Directory group to local Win2K Group

Posted on 2004-09-16
3
306 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
  • 2
3 Comments
 
LVL 83

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 83

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now