Script to add Domain Admins into local administrators group

Asked By 30 points N/A Posted on -
qa-featured

Hello,

Script to add Domain Admins into local administrators group.

Any help with a script that can achieve this?

Thanks

 

SHARE
Answered By 0 points N/A #113237

Script to add Domain Admins into local administrators group

qa-featured

Below you’ll find the Vbscript that can be used. It adds “YOUR DOMAIN Domain Admins” to the local Administrators group. The GPO needs to be created in the source domain. 

Using this it will be much easier to migrate a user’s PC, without having to add it on each workstation by hand (one condition, each workstation needs reboot to process this computer based GPO).

Script:

*****************

Dim WSHShell, WshSysEnv

Set WshShell = WScript.CreateObject("WScript.Shell")

Set WshSysEnv = WshShell.Environment("PROCESS")

On Error Resume Next

UserString = WshSysEnv("COMPUTERNAME")

GroupString = "Administrators"

Set GroupObj = GetObject("WinNT://" & UserString & "/" & GroupString)

GroupObj.Add ("WinNT://YOUR DOMAIN/Domain Admins")

Set GroupObj = Nothing

Set WshShell = Nothing

Set WshSysEnv = Nothing

Wscript.Quit

*****************

The script assumes that the local administrators group is “Administrators”! If an OS language other than English is used (as we saw in Germany), the script need to be changed to the right group name for that particular language!

 

Related Questions