Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a user to the local computers admin group

Status
Not open for further replies.

bluelinetravis

IS-IT--Management
Dec 21, 2009
2
US
Hello All,

I have recently taken over support for a company and I am trying to patch up some security issues.

I have this script:
Code:
strComputer = "ComputerName"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://Domain/Desktop Admins,group")
objUser.Add(objGroup.ADsPath)

But I get back "Could not find group: Line 4"

I am assuming that it is because its looking for domain admins on the target rather than in AD....but how do I provide it the AD group?
 
which is line 4?do you have on error resume next on? where is the real failure?

which machine are you running this on? and under what credentials?

strComputer = "ComputerName"
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Wscript.Echo "objGroup.Name=" & objGroup.Name
Set objUser = GetObject("WinNT://Domain/Desktop Admins,group")
Wscript.Echo "objUser.Name=" & objUser.Name
objUser.Add(objGroup.ADsPath)
 
Actually, I think the real error is giving users local admin rights...

;)

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
 
The add is applied incorrectly. It is the other way around.
>objUser.Add(objGroup.ADsPath)
[tt]objGroup.Add(objUser.ADsPath)[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top