JSI Tip 9725. How can I return the shortServerName, printShareName, printerName, location, portName, serverName, driverName, and distinguishedName of the Active Directory published printers?

Jerold Schulman

September 11, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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

PubPrint.bat contains:

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



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like