@echo off

IF %1.==. GOTO USAGE

set PRINTERNAME=%1%

rem remove the printer ...
powershell -Command ^
"$checkPrinterExists = Get-Printer -Name '%PRINTERNAME%' -ErrorAction SilentlyContinue ; ^
if ($checkPrinterExists) { ^
  Remove-Printer -Name '%PRINTERNAME%' -Verbose ^
} else { ^
  Write-Host 'Printer %PRINTERNAME% already removed' ^
}"

GOTO END

:USAGE
echo "usage: %0 <PRINTERNAME>"

:END
