[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 640
  • Last Modified:

Get error trying to list published printers in AD

following script errors on line 13
table does not exist    code 80040E37

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT printerName, serverName FROM " _
 & " 'LDAP://DC=landam,DC=com' WHERE objectClass='printQueue'"
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
 Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
 Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
 objRecordSet.MoveNext
Loop
0
garylouis
Asked:
garylouis
1 Solution
 
sapbucketCommented:
which is line 13? looks to me like you have line wrap on.
0
 
garylouisAuthor Commented:
objCommand.CommandText = "SELECT printerName, serverName FROM " _
 & " 'LDAP://DC=landam,DC=com' WHERE objectClass='printQueue'"


figured it out should be

objCommand.CommandText = "SELECT printerName, serverName FROM " _
 & " 'LDAP://DC=landam,DC=landamerica,DC=net' WHERE objectClass='printQueue'"

used following to figure out -

 Get Domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomain = objRootDSE.Get("DefaultNamingContext")

WScript.Echo strDomain ' This is Extra line Guy put in to test

found on a great script error site -
http://www.computerperformance.co.uk/Logon/code/code_80040E37.htm
0
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now