Description: Takes a domain user account and adds it to the local administrators group on a PC
Option Explicit
On Error Resume Next
'Define Variables
Dim CompName, objGroup, objUser, OSName, WshShell
' Set up an Instance of the WScript.Shell Object
Set WshShell = CreateObject("WScript.Shell")
'set access to Env vars
CompName = WshShell.ExpandEnvironmentStrings("%ComputerName%")
OSName = WshShell.ExpandEnvironmentStrings("%OS%")
' If Windows 9x - Then Quit
IF NOT OSName = "Windows_NT" Then
WScript.Quit
End If
' Access Local Admin Group
Set objGroup = GetObject("WinNT://" & CompName & "/Administrators")
' Access Domain User SOE/Deploy
Set objUser = GetObject("WinNT://ChangetoDomainName/ChangeToRequiredUserName")
' Use ADsPath Method to add user: objUser to Local Admin group: objgroup
objGroup.Add(objUser.ADsPath)
Set CompName=Nothing
Set objGroup=Nothing
Set objUser=Nothing
Set OSname=Nothing
WScript.Quit