Skip to content

Set domain user account as local admin TS

Featured Replies

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

  • Author

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

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.

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.