Automating Uninstallation And Re Installation Of Network Printers With PowerShell

Usually to uninstall and reinstall a printer there are several steps and settings that you need to navigate through, usually involving control panel, print management, services and device manager.

You might be doing this to troubleshoot a printer problem or an issue with a driver for example, or maybe you're not sure if the PC has pulled down the right driver from the print server.

To completely uninstall a printer and printer drivers from a computer you would usually follow the following steps.

Remove the printers from control panel or settings in windows 10
Stop and restart the print spooler service
Open print management and navigate to print servers
Remove the driver package from the PC any print management
Navigate back to the print server in explorer
Reconnect to the printers and reinstall drivers

Doing this manually on multiple machines means a lot of steps that you have to go through and a lot of different settings and applications.

PowerShell makes this much easier as you can write a simple script that will do all of these steps for you automatically, the following script will allow you to remove a printer uninstall the driver's and reinstall the printer for you.

Get-Printer | ? ComputerName -like '*Print-Server-Name*' | Remove-Printer

$CheckSpooler = Get-Service -Name 'spooler'
if ($CheckSpooler.status -like 'running')
    {
    Stop-Service -Name 'spooler' -PassThru -OutVariable StopSpooler
    if ($StopSpooler.status -notlike 'Stopped') {Echo 'Failed to stop Print spooler'}
    Start-Service -name 'spooler' -PassThru -OutVariable StartSpool
    if ($StartSpool.status -notlike 'Running') {Echo 'Failed to start Print spooler'}
    }
    Get-PrinterDriver | ? Name -like 'Konica Minolta*' | Remove-PrinterDriver
    Add-Printer -ConnectionName '\\Print-Server-Name\Printer-Name'

Now with the above code in PowerShell just replace the names of the print server and the printer as well as the name of the driver and all of these steps will be done automatically for you with PowerShell.

Was this helpful?

Yes No


Comments