Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add Active Directory group to local Win2K Group

Posted on 2004-09-16
3
Medium Priority
?
318 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Sometimes you might need to configure routing based not only on destination IP address, but also on a combination of destination IP address (or hostname) and destination port number. I will describe a method how to accomplish this with free tools. …
Resolve DNS query failed errors for Exchange
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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