Kunne desværre ikke få dit script til at makke ret.
Men kom selv frem til følgende.
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = "SELECT distinguishedName FROM '
LDAP://dc=domain,dc=local'WHERE objectCategory='user'AND sAMAccountName='" & strSam & "'"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount > 0 Then
'WScript.Echo "Der blev fundet en bruger ved dette navn" & strSam & ""
objExcel.Cells(intRow, 9).Value = "Fejl bruger findes"
intFejl = intFejl + 1
Else
' Her oprettes brugeren
End If