Choose your language

Choose your login

Contact us

Removing duplicate printers after a server name change

THE PAGE APPLIES TO:

“Help! I’m a PaperCut systems administrator, and some or all of our print queues are listed twice in PaperCut. What is the fastest way to get rid of the duplicates?”

When would you need to rename a printer in PaperCut?

PaperCut works by detecting local print queues on your server or workstation, then they appear in the web interface of the PaperCut server for easy management. To uniquely identify each print queue, PaperCut uses the combination of the hostname of the print server and the name of the print queue, like printsrv01\library-color-printer. If those details change, PaperCut will assume this is a new print queue and another printer will appear in the Printers list.

So you may see a ‘duplicate’ or similar printer names appear in PaperCut if…

  • The print queue was renamed on the server
  • The print server’s hostname changed, as described here

If one of the above things happens, PaperCut will detect a new print queue and a new printer object will be created in PaperCut. In the screenshot below, you can see how the print server was renamed (from oldservername to newservername) and now each print queue is duplicated.

This might not be ideal in some situations, but thankfully there are a couple ways to fix this depending on whether you have a few printers or a lot of printers.

How to rename a single printer in PaperCut

If you want to carry over the history and settings from the ‘old’ printer to the new one, then the best way is to follow our section in the manual that covers How to Rename a Printer.

(Let me save you a click: log into your PaperCut server as an admin → open Printers → select the printer in question → click Rename this printer → fill in the new details and check the box “If a printer with the new name already exists, delete and replace it.”)

How to rename many printers in PaperCut at once

Renaming a printers in bulk is also possible using Server Commands. This might be the preferable option if you have hundreds or thousands of print queues tracked by PaperCut that need to be renamed. If you decide to take this route, then these two server commands will be useful to delete the superfluous print queues and rename the olds to the new name:

  • delete-printer <server_name> <printer_name>
  • rename-printer <server_name> <printer_name> <new_server_name> <new_printer_name>

Keep in mind…

  • Print queue names are case sensitive on some operating systems, so be sure to enter the printer’s name exactly as it appears in the OS (and to use the queue name, not the share name).
  • After making any changes, be sure to test printing and ensure that print jobs are logged under the correct printer in PaperCut.

Is there a PowerShell script I can run to do that?

We’re glad you asked! In fact, there is one we’ve written that you can run in PowerShell on a Windows PaperCut server. Here’s what you should know:

  • This script will delete all of the superfluous print queues with the new server name, including their history and settings. Then it will rename all of the old print queues, so that they have the correct server name.
  • This script assumes you are running PaperCut MF and it is installed in the default application directory. If that is not the case, then please update the file path in the script.
  • You should only run this after hours and make a backup of PaperCut beforehand.
  • If you aren’t sure if this script is right for the situation, please reach out to PaperCut Support.
# Automatically rename all print queues in PaperCut to change the server name.
# To be run after a server name change or migration.
# Written by PaperCut Support. February, 2020.

$old_server_name = Read-Host -Prompt "Type the server's old hostname and hit enter"
$new_server_name = Read-Host -Prompt "Type the server's new hostname and hit enter"
Write-Host -ForegroundColor YELLOW "Merging these queues will replace the information in the new queue with the information from the original queue. Any data that has been tracked under the new duplicate queue will be lost. Please type CONFIRM and press ENTER to proceed"
$UserAccepts = Read-Host
if($UserAccepts.toUpper() -match "CONFIRM" ) {
cd 'C:\Program Files\PaperCut MF\server\bin\win'
$printerlist=.\server-command list-printers
foreach ($printer in $printerlist) {
if ($printer -like "$old_server_name*") {
#strip off the print server name and \ character to get the queue name
$printer_name = $printer.Replace($old_server_name+"\","")
Write-Host "Deleting superfluous printer "$new_server_name"\"$printer_name
.\server-command delete-printer $new_server_name $printer_name
Write-Host "Renaming printer from "$old_server_name"\"$printer_name" to "$new_server_name"\"$printer_name
.\server-command rename-printer $old_server_name $printer_name $new_server_name $printer_name
}
}
}
else{
Write-Host -ForegroundColor RED "Data loss not confirmed, exiting script."
Start-Sleep -s 3
exit
}

Still have questions?

Let us know! We love chatting about what’s going on under the hood. Feel free to leave a comment below or visit our Support Portal for further assistance.


Categories: How-to Articles , Print Queues


Keywords: change printer name , rename printers after migration , server hostname change

Comments

Last updated March 15, 2024