ShuttleDIK
asked on
VB or Batch script to add Domain Users to local Power Users group
Hi,
I've tried searching for an answer on this and found some useful material, but nothing that addresses my problem exactly. I was hoping someone could direct me further.
I would like to run a script that goes accross the network and adds "Domain Users" to the local "Power Users" group on selected PCs. I don't need a true loop function, though that wouldn't hurt. I don't have a problem hard coding the computer names.
i guess my main questions are syntax and whether VBS or straight batch.
Thanks so much for your help.
-Dik
I've tried searching for an answer on this and found some useful material, but nothing that addresses my problem exactly. I was hoping someone could direct me further.
I would like to run a script that goes accross the network and adds "Domain Users" to the local "Power Users" group on selected PCs. I don't need a true loop function, though that wouldn't hurt. I don't have a problem hard coding the computer names.
i guess my main questions are syntax and whether VBS or straight batch.
Thanks so much for your help.
-Dik
It should be obvious but just to be clear, you need to change/amend the items on line 32, 38, 39, and 42
Krystian
Krystian
ASKER
Wow! That's awesome. Thank you so much for such a complete addressing of my request.
I'll test it out tomorrow morning and let you know if I run into any trouble. It doesn't look like I will, though.
i was thinking about running a script to reverse the assignments, but with the problem I'm addressing, it looks like manual reversal of the change on a 'per case' basis is actually the way to go.
Thanks again for your thorough assistance!
I'll test it out tomorrow morning and let you know if I run into any trouble. It doesn't look like I will, though.
i was thinking about running a script to reverse the assignments, but with the problem I'm addressing, it looks like manual reversal of the change on a 'per case' basis is actually the way to go.
Thanks again for your thorough assistance!
ASKER
I was able to test the script today and I immediately ran into an error:
"(52, 2) Microsoft VBScript runtime error: ActiveX component can't create object: 'Scripting.FileSystemObjec t'"
Any ideas?
"(52, 2) Microsoft VBScript runtime error: ActiveX component can't create object: 'Scripting.FileSystemObjec
Any ideas?
ASKER
Ok, I researched that error some and for the most part it seems to show that Scripting isn't fully or properly installed on the machine(s) on which I was running the script.
I have tried it on a third machine and am not getting that error - HOWEVER (isn't there always one of these??) I'm now getting :
ChgLGrp.vbs(68, 2) Microsoft VBScript runtime error: Type mismatch
The section of script pertaining to the error is in the snippet. It seems as though the engine has a problem with the ("") designation.
I have tried it on a third machine and am not getting that error - HOWEVER (isn't there always one of these??) I'm now getting :
ChgLGrp.vbs(68, 2) Microsoft VBScript runtime error: Type mismatch
The section of script pertaining to the error is in the snippet. It seems as though the engine has a problem with the ("") designation.
' Create an array of compuiters from the file
arrComputers - Split(strResults, vbNewLine)
strResults = ""
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That makes sense ;]
And since I'm not getting the Object error on this workstation, let's wait on that error. I don't need to go around installing scripting updates if I have a machine that will run it... ;]
Thanks again!!
And since I'm not getting the Object error on this workstation, let's wait on that error. I don't need to go around installing scripting updates if I have a machine that will run it... ;]
Thanks again!!
ASKER
Great! Just ran the script successfully.
I added the computer name to the confirmation Echo, too.
Thanks for the awesome assistance!
I added the computer name to the confirmation Echo, too.
Thanks for the awesome assistance!
ASKER
I've been known to 'Fat Finger' code from time to time, too ;]
Thanks for the assistance, Krystian.
Thanks for the assistance, Krystian.
I've written a VBScript that should do what you want.
It takes a list of computers from a file (1 per line) and uses that to go to the computer and add the AD group to the Local computers group (I've specified the names of the groups but check them)
Things to note:
Open a command prompt and run the script like
cscript.exe scriptname.vbs
Hope it's what you are looking for :-)
Regards
Krystian
Open in new window