Using WSH (VB) to add a domain user to local administrator's group under Windows XP/2003
Posted on 2006-04-26
I'm working on a script that I want to be able to run on my admin station and do the following:
- Query user for a domain user account name (service account)
- For each workstation(XP) on a list, add that domain user to the local administrator's group
strComputer = [computer name variable]
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objUser = GetObject("WinNT://" & strComputer & "/" & [user name variable] & ",user")
I also tried with:
Set objUser = GetObject("WinNT://" & strComputer & "/DOMAIN\" & [user name variable] & ",user")
I get a "Exception: Unknown Exception" error every time... I know that this is probably because I'm trying to change a domain account instead of a local account, but I can't find any info on how I would do this for a domain account. Any suggestions?
And yes, the user executing the script has full administrative privilages on the target machines.
And yes, I'm kind of new to programming this kind of script, why do you ask?