Removing Network and Local Printers from End User Machines

My organization was performing a maintenance task that required me to remove all printers from every workstation in the company. As I was told about this only a few hours before the changes needed to be made and I have 34 sites worldwide, time was of the essence. Also, since the majority of our machines are deployed via GPO and configured to be IP ports, I needed to create a script that removed both local printers as well as network printers that may be mapped.

Here’s what I came up with. WARNING: THIS WILL REMOVE EVERY PRINTER, INCLUDING ITEMS SUCH AS PDFCREATOR:

strComputer = “.”

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)

Set colInstalledPrinters = objWMIService.ExecQuery _
(“Select * From Win32_Printer Where Local = True”)

For Each objPrinter in colInstalledPrinters
objPrinter.Delete_

Next

Set colNetworkPrinters = objWMIService.ExecQuery _
(“Select * From Win32_Printer Where Network = True”)

For Each objPrinter in colNetworkPrinters
objPrinter.Delete_

Next

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s