Sign in with
Sign up | Sign in
Your question

[vbscript]Adding domain user to local admin

Last response: in Windows 7
Share
January 17, 2013 1:00:56 PM

Here is my situation:

I'm trying to run a script at the end of sysprep that will add a Domain group to the local Admins group. I found a few scripts while searching around, but none will work for my application.

This is what I have so far.

  1. SET objNet = CREATEOBJECT("WScript.Network" )
  2.  
  3. ' Set the user you want to make local administrator here
  4. strUser = "<username here>"
  5.  
  6. strNetBIOSDomain = objNet.UserDomain
  7. strComputer = objNet.ComputerName
  8.  
  9. SET objGroup = GETOBJECT("WinNT://" & strComputer & "/Administrators,group" )
  10. SET objUser = GETOBJECT("WinNT://" & strNetBIOSDomain & "/" & strUser & ",user" )
  11.  
  12. ' ignore error if user is already a member of the group
  13. ON ERROR RESUME NEXT
  14. objGroup.Add(objUser.ADsPath)
  15. ON ERROR GOTO 0


The problem I'm having is that I need to be able to provide a username and password of a domain admin so that it can authenticate. I need to know how to do this when I try to add the user.
January 17, 2013 1:26:08 PM

What Server OS are you running, 2003, 2005, 2010? and Im also assuming XP Pro?
m
0
l
January 17, 2013 2:39:04 PM

We are running a mixed server os, both server 2003 and 2008, however our domain level is 2000. And I would be doing this customization on a Windows 7 PC.
m
0
l
Related resources
January 17, 2013 3:48:23 PM

Although I would love to be able to accomplish this with the use of GPO's, however, I do not have access to the GPO, thus the reason I'm doing it via a vbscript.
m
0
l
!