0

I need a little help making a script that removes all printers, ports and drivers apart from the default microsoft offerings such as fax and print to pdf, and any epson printers as those are for labels and never an issue, for the purpose of fixing any printer related issues and starting as if the computer has just been imaged fresh.

So far I have this:

Get-Printer | Where-Object { $_.Name -notmatch "PDF|txt|fax|usb|enhanced|epson|microsoft" } | Remove-Printer

Get-Printerdriver | Where-Object { $_.Name -notmatch "PDF|txt|fax|usb|enhanced|epson|microsoft" } | remove-printerdriver

Get-Printerport | Where-Object { $_.Name -notmatch "PDF|txt|fax|usb|enhanced|epson|microsoft" } | remove-printerport

I feel there would perhaps be a better way to do this and also add a bit of feedback so the person using the script knows what has been deleted and if anything failed to remove.

Any help or pointing in the right direction would be greatly appreciated.

2
  • I don't see any problem with what you are using here. What you can do is write a Write-Host or Write-Output command up top and state, "This list of printers will be removed from this computer" and then run (Get-Printer | Where-Object { $_.Name -notmatch "PDF|txt|fax|usb|enhanced|epson|microsoft" }).Name, let the remove logic run next, and then run another line that says, "These printers are on your computer" and then run (Get-Printer ).Name. You basically have everything you need though other than those trivial adjustments. Let me know what you think abou that. Commented Jan 19, 2023 at 14:57
  • Thank you, I just needed a way of feeding back and thats ideal. Much appreciated.
    – Sharpe
    Commented Jan 20, 2023 at 11:04

0

You must log in to answer this question.

Browse other questions tagged .