Query AD for Printer info

Expanding on my code to query single printer information, I found I could pull all networked printers from Active Directory(AD). This will help in cleaning up the naming standard for all our printers. Hopefully making DNS cleaner by using a single standard for host(A) records. Final file is written to c:\printer-info.csv. The attached script will return the following:

  • Printer name
  • Server name - where hosted
  • Port - name of printer port (local or network)
  • Share name
  • Host address (what the port points to) - requires Windows 2003 or XP print server
  • Protocol (RAW or LPT) - requires Windows 2003 or XP print server
  • RAW Port (if using RAW) - requires Windows 2003 or XP print server
  • SNMP Community (if enabled) - requires Windows 2003 or XP print server
  • Host Name - as pulled from DNS - requires IP Address, captured in Host Address field Windows 2003 or XP print server

To get the script to run, you will need to modify this line (#19) to match your current environment.

Const MyDomain = "DC=my_domain_goes_here,DC=com"

Sources: Microsoft, Microsoft, and Geek Speak