Created
May 5, 2018 02:18
-
-
Save brettfreer/b90af01495f4d400b49a69e7d71d8dcd to your computer and use it in GitHub Desktop.
Removing all printers on a PC linked to a common server using PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$PrintServer = "\\old_print_server" | |
$Printers = Get-WmiObject -Class Win32_Printer | |
ForEach ($Printer in $Printers) { | |
If ($Printer.SystemName -like "$PrintServer") { | |
(New-Object -ComObject WScript.Network).RemovePrinterConnection($($Printer.Name)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment