This script removes Listed printer names in the list
Tested in Windows 10
Run as Local System User
#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name
printers_list = itsm.getParameter('PrintersList') # Provide the printer names need to be remove
import os
import re
os.chdir("C:\Windows\System32\Printing_Admin_Scripts\en-US")
list_printer=os.popen("wmic printer get Name ").read()
list_printer=list_printer.splitlines()[1:-1]
filtered_list=[]
print printers_list
for i in list_printer:
if i.strip() in printers_list:
print i
filtered_list.append(str(i).strip())
else:
pass
if not filtered_list:
print "No printers Found in the list"
else:
for i in filtered_list:
command='CSCRIPT prnmngr.vbs -d -p "%s"'%i
print command
print os.popen(command).read()
print "Removed "+i
print("Sucessful")
Comments