Jump to content


  • 0
revingtosh

Script to remove all unknown printers from registry

Question

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

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites

  • 0

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?

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.