I have been tasked with removing several hundred local printers. I have a spread sheet with PC names and printer names and I am trying to remove the printers using the WMI-Object method. I have tried using the Remove-Printer method and I frequently get a message saying the print spooler is not available but when I use the WMI method it works perfectly.
If I user this command
Get-WMIObject -ComputerName pdd21963 -query "Select * From Win32_Printer Where Name = 'hp designjet 4520 - n318'" | Remove-WmiObject
The printer is immediately removed. However, when I use the script below I don't get any error messages but the printers are not removed.
Import-Csv -path 'C:\removeprinters.csv' | foreach-object {
Get-WMIObject -ComputerName $_.comp -query "Select * From Win32_Printer Where Name = '$_.name'" | Remove-WmiObject
}
Any help would be greatly appreciated.
Thanks,
Andy