We recently just sunsetted an old print server and my users are not following procedure for removing the printers tied to the old server so its causing confusion for them with new printers having similar names, is there an easy cmd or powershell script i can run that would pull all printers on our old print server
CodePudding user response:
You mean deinstallation of the printers on the clients? You can do that with PowerShell:
$Printers = Get-Printer
foreach ($Printer in $Printers)
{
if ($Printer.Name -eq "OldPrinter" -or $Printer.Name -eq "OldPrinter2")
{
Remove-Printer -Name $($Printer.Name)
}
}
You can run that on each Computer or you add the -ComputerName
parameter for Get-Printer to do that via PowerShell Remoting (need to be activated)
CodePudding user response:
Then perhaps you want something like this:
$oldServer = 'YeOldePrintServer'
Get-Printer | Where-Object { $_.Location -like "*$oldServer*" } | Remove-Printer -WhatIf
The -WhatIf
switch makes the command not removing anything, but instead will only show in the console what WOULD happen. This way you can test first to see if the correct printer(s) wil be selected for deletion.
Once satisfied, remove that safety switch and run again.