Using ADFind.exe freeware, I have scripted PubPrint.bat to return the shortServerName, printShareName, printerName, location, portName, serverName, driverName, and distinguishedName of the Active Directory published printers, using a semi-colon delimited format.

The syntax for using PubPrint.bat is:


PubPrint.bat contains:

                              @echo off                              setlocal                              set qry=ADFIND -default -nodn -f "(objectClass=printQueue)" distinguishedName printerName printShareName portName driverName location shortServerName serverName                              for /f "Skip=3 Tokens=1* Delims=:" %%a in ('%qry%') do (                               set p1=%%a                               set p2=%%b                               call :attr                              )                              endlocal                              goto :EOF                              :attr                              set p1=%p1:~1,6%                              set p2=%p2:~1%                              if "%p1%" EQU "distin" set dn=%p2%&goto :EOF                              if "%p1%" EQU "locati" set loc=%p2%&goto :EOF                              if "%p1%" EQU "server" set sn=%p2%&goto :EOF                              if "%p1%" EQU "portNa" set port=%p2%&goto :EOF                              if "%p1%" EQU "driver" set drvr=%p2%&goto :EOF                              if "%p1%" EQU "printS" set shr=%p2%&goto :EOF                              if "%p1%" EQU "printe" set prtn=%p2%&goto :EOF                              if "%p1%" EQU "shortS" goto srvsn                              goto :EOF                              :srvsn                              set srvsn=%p2%                              @echo "%srvsn%";"%shr%";"%prtn%";"%loc%";"%port%";"%sn%";"%drvr%";"%dn%"                              set shr=                              set loc=                              set port=