Skip to content

Script to remove all unknown printers from registry

Featured Replies

Hi,

 

I need a script which will enable me to achieve the following goals if someone could assist.

 

All workstations are either WIn7 or XP (just a tiny amount of XP)

Printer installs on each device are currently of an unknown ilk (each one has been installed manually!)

 

The script needs to:-

 

Remove ALL local and network printers

Add the following printers

 

\\printserver\mono

\\printserver\colour

 

We are only currently moving to print servers (i know, i know.. !) and i would like to clear up each workstation from a printing perspective and start again.

 

Also, would you deploy this via policy? Or would you use SCCM2007. We have both.

 

Any help would be greatly received.

 

Rev

Removing all network printers is not that difficult with Powershell on the win7 machines. This one liner will remove all network printer connections:

 

Get-WMIObject Win32_Printer | where{$_.Network -eq ‘true’} | foreach{$_.delete()}

 

 

But this will only remove the connections If you want to remove the drivers also you need to use prnmgr.vbs see: http://technet.microsoft.com/en-us/library/cc725868(WS.10).aspx

 

The script i used earlier this year to achieve almost the exact same thing as you was this script.:

 

 

#Delete_printers.ps1

Write-Host ‘Tar bort alle Nettverksskrivere fra “Enheter og skrivere”‘ -ForegroundColor Green

Get-WMIObject Win32_Printer | where{$_.Network -eq ‘true’} | foreach{$_.delete()}

Write-Host ‘Restart Print Spooler’ -ForegroundColor Green
(get-wmiobject -Class win32_service -filter “Name=’Spooler’”).stopservice()
sleep 5
(get-wmiobject -Class win32_service -filter “Name=’Spooler’”).startservice()
sleep 10

Write-Host ‘Sletter Driverne’ -ForegroundColor Green
Invoke-Expression “cscript C:\Windows\system32\Printing_Admin_Scripts\en-US\prndrvr.vbs -x”

 

 

After this is run use GPOs or a login script to set the new printers.

  • 2 years later...

I need a script by using I can delete non commented printers which are installed on print server.

 

Also want to add that script in batch file to run it automatically in sheduled time.

 

can you please help me to create such script and batch file?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.