$oldErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'SilentlyContinue' # Remove the printer first, then remove the printerport Get-Printer -Name 'LaserJet Marketing' | Remove-Printer Get-PrinterPort -Name 'LPT1:' | Remove-PrinterPort $ErrorActionPreference = $oldErrorActionPreference