nikolai5005
MIS
Hey All,
I'm in a bit of a bind with a project for work and could use some assistance. I have almost all of the hta code complete. Long story short our users will use this hta to install printers on a local Win7 machine before connecting to a Citrix session which will redirect that printer.
I am using the below code to pull back the serverName, printerName, and location just fine, where I am struggling is pulling back the Comment or Description field depending on how your looking at it.
If I add comment to the "objCommand.CommandText" it comes back blank.
If I add comment to the "objCommand.CommandText" it comes back blank.
If I add description to the "objCommand.CommandText" it throws an error, the data is invalid
If I add Description to the "objCommand.CommandText" it throws an error, the data is invalid
I know there is data in this property, DSQuery will return the desired results but is slower and messier and I'd prefer not to use it if at all possible.
I'm in a bit of a bind with a project for work and could use some assistance. I have almost all of the hta code complete. Long story short our users will use this hta to install printers on a local Win7 machine before connecting to a Citrix session which will redirect that printer.
I am using the below code to pull back the serverName, printerName, and location just fine, where I am struggling is pulling back the Comment or Description field depending on how your looking at it.
If I add comment to the "objCommand.CommandText" it comes back blank.
If I add comment to the "objCommand.CommandText" it comes back blank.
If I add description to the "objCommand.CommandText" it throws an error, the data is invalid
If I add Description to the "objCommand.CommandText" it throws an error, the data is invalid
I know there is data in this property, DSQuery will return the desired results but is slower and messier and I'd prefer not to use it if at all possible.
Code:
' List All Published Printers
c = 0
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, location, Comment from " _
& " 'LDAP://DC=firm,DC=saulewing,DC=net' where objectClass='printQueue'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
If c <= 5 Then
WScript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
WScript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
WScript.Echo "Printer Location: " & objRecordSet.Fields("location").Value
WScript.Echo "Printer OTHER: " & objRecordSet.Fields("Comment").Value
objRecordSet.MoveNext
c = c + 1
Else
WScript.Quit 8888
End If
Loop