Solved

Add Active Directory group to local Win2K Group

Posted on 2004-09-16
3
309 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sonicwall SOHO SSL-VPN no LAN Access 5 72
IPhone using PC internet 17 59
Running VB/Batch script through Group policy 30 79
Office 2016 Network Activation 2 16
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. …
A common practice in small networks is making file sharing easy which works extremely well when intra-network security is not an issue. In essence, everyone, that is "Everyone", is given access to all of the shared files - often the entire C: drive …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

12 Experts available now in Live!

Get 1:1 Help Now