I'm quite new to PowerShell and need some advise/help from you. The goal is to delete all mapped printers that are listed in a file.
Thanks in advance for your help.
Your where-object statement is actually comparing anything to the list of printers. Also its inefficient to read the file of printer names for every object on the pipeline
Run this to test that you're seeing the printers you expect
There isn't a Delete method on the Win23_Printer class so try
Thanks for your fast reply. The command you suggest is working as excepted, thanks a lot. Good hint regarding getting content of file.
Get-WmiObject -Class Win32_Printer | Where-Object -Property ShareName -In $Printers | Remove-WmiObject
What is better, WmiObject or CimInstance? Does it matter?
Do you have an idea or advise how to handle printers that are set as "default printers"? When I remove such a printer trough the script, none of the remaining printers get assigned as "default printer".
Thanks and best regards,
You can refer this link
Thanks for the link.
@Richard Siddaway, thanks for the post.
You must be logged in to reply to this topic.