Jump to content


  • 0
Johnson

Set domain user account as local admin TS

Question

Hi.

 

I would like help with my Task Sequence (it's one of my last step)

 

In my task sequence I add the computer to our domain (successfully) and I want to add a "domain user account" (e.g mydomain\ed) to the Administrator Group on the computer that i deploy. So do anyone know if I can create a vbs script, or something similar, to get an prompt where I can type in the username?

 

Thanks in advanced.

 

/Johnson

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thanks Peter.

 

I did find a "semi-solution" in that page. Created a bat with "net localgroup administrators "mydomain\domain users" /add" but then I manually need to remove "domain users" and add the "username" when I have logged in to Windows.

 

The perfect solution for me would be a prompt where I can typ in the username which would be added to localgroup Administrator

Do you or anyone else have an idea if it's even possible?

 

/Johnson

Share this post


Link to post
Share on other sites

  • 0

Set net = WScript.CreateObject("WScript.Network")

local = net.ComputerName

DomainName = "DOMAINNAME"

UserAccount = "USERNAME/GROUPNAME"

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

set colOperatingSystems = objWMIService.ExecQuery _

("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems

'GERMAN OS

If objOperatingSystem.OSLanguage = "1031" Then

set group = GetObject("WinNT://"& local &"/Administratoren")

End If

'ENGLISH OS

If objOperatingSystem.OSLanguage = "1033" Then

set group = GetObject("WinNT://"& local &"/Administrators")

End If

Next

on error resume next

group.Add "WinNT://"& DomainName &"/"& UserAccount &""

 

 

This script works pretty fine. Just make sure to run it after Domain Join. You may probably cut the language selection part.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.