Script to Delete Redirected Printers Based on Name?
Posted on 2010-08-16
ENVIRONMENT: Very busy terminal server running Server 2003.
SITUATION: Many users have many auto-discovered printers which map in to TS session, such as "Auto HP LaserJet 4000N (from USERPC) in session 17". Also, there are many printers redirected (such as Adobe PDF, eFax, XPS Document Writer, Quickbooks PDF writer, etc) from user PCs which do NOT need to be present in the RDP session.
CONDITION: Spooler load is high, with sometimes 100 or more of these un-needed redirected printers.
NEED: Script we can run via sceduled task every few minutes, to delete certain redirected printers by name to clean out the ones not needed. Examples:
- Delete all printers whose name starts with "Auto " (to kill the redirected auto-discovered printers)
- Delete all printers whose name starts with "eFax 4.4 (from "
- Delete all printers whose names start with "Microsoft XPS Document Writer (from "
And so forth. Note that the "(from " is necessary so only the redirected instances are matched, not the ones installed locally on the server.
Any recommendations or sample scripts that can be run on the print spooler object would be greatly appreciated.