I'm looking for a script that will prompt a user for a computername, then search AD for that computername, and delete it. The script needs to be able to run from an XP machine that is not a member of the domain (yet).
I've found several vbscripts on EE's website that query AD and delete computer accounts, and they work great as long as you run them from a machine that is on the domain.
Basically, I'd like a script that prompts the user for not only the machine name they'd like to delete, but also for their admin username and password. I've found one vbscript on another post courtesy of kelvinight, but it needs to be able to prompt the user for network credentials as well as the computer name...
Any help would be appreciated. I'm including the vbscript from kelvinight below. Here's the question that came from:
Const ADS_SCOPE_SUBTREE = 2
Const ADS_SECURE_AUTHENTICATION = 1
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "test\admin"
objConnection.Properties("Password") = "home"
objConnection.Properties("Encrypt Password") = True
objConnection.Properties("ADSI Flag") = 1
strComputer = "test"
strDomain = "srv.test.com"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 100
objCommand.Properties("Cache Results") = False
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT ADsPath FROM 'LDAP://" & strDomain & "' WHERE objectCategory='computer' " & _
"AND Name='" & strComputer & "'"
Set objRecordSet = objCommand.Execute
strADsPath = ""
While Not objRecordSet.EOF
strADsPath = objRecordSet.Fields("ADsPath").Value
If strADsPath = "" Then
MsgBox "Computer not found."
MsgBox "Computer path: " & strADsPath
Set objNS = GetObject("LDAP:")
Set objComputer = objNS.OpenDSObject(strADsPath, "test\admin", "home",ADS_SECURE_AUTHENTICATION)