Skip to content

Instantly share code, notes, and snippets.

@brettfreer
Created May 5, 2018 02:18
Show Gist options
  • Save brettfreer/b90af01495f4d400b49a69e7d71d8dcd to your computer and use it in GitHub Desktop.
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
$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