I want to run ADSI script to check if there is a computer in domain. If I find this computer account already exists in domain then you can join domain. My script as below.
But it can't work in winpe. it said "Table does not exist" of code "Set objRecordSet = objCommand.Execute". BTW, this script run fine in standard system and the boot image had been installed all cab plugin(Script,WMI...).
I know it should miss some ADSI related plugin. I want to know how to make this script work or how to check if there is a computer acount in domain.
strUser="Name" strPassword="Password" PcName="Computer" Const ADS_SCOPE_SUBTREE = 2 Const ADS_SECURE_AUTHENTICATION = &H1 Const ADS_SERVER_BIND = &H200 Dim objConnection, objCommand, objRecordSet Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Properties("User ID") = strUser objConnection.Properties("Password") = strPassword objConnection.Properties("Encrypt Password") = True objConnection.Properties("ADSI Flag") = ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://dc=abc,dc=com' WHERE objectCategory='computer' AND Name='" & PcName & "'" Set objRecordSet = objCommand.Execute If objRecordSet.PageCount Then IsPCname="True" Else IsPCname="False" End If WScript.Echo IsPCname