HI there,
I found this script that will add a domain admin account to the local administrator group for a machine but i need it to prompt for the domain admin credentials to use and then also prompt for the user account to add to the local administrator group. ALso don't i need to put strDomain=MyDomain somewhere and reference it in the script or does the script go off the domain the machine is joined to?
strDomainAdmin = InputBox("Enter account to add AD user to the local admin group that has domain admin rights")
strPassword = InputBox("Enter the account password")
strUser = InputBox("Enter user to be added to local admin group")
Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_USE_ENCRYPTION = &H2
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
Set objNS = GetObject("WinNT:")
Set objUser = objNS.OpenDSObject("WinNT://mydomain/" & strUser & ",user", _
strUser, strPassword, ADS_SECURE_AUTHENTICATION Or ADS_USE_ENCRYPTION)
If Not objGroup.IsMember(objUser.ADsPath) Then
objGroup.Add(objUser.ADsPath)
Wscript.Echo strUser & " added to local administrators."
End If
Many thanks!!!! -berto