migrate printer server

Alex Alexandre 0 Reputation points
2023-02-13T18:48:11.3833333+00:00

i need some help migrating printers from server to another server i found a script online to migrate the printer script not working for me.


    .SYNOPSIS
        Logon Script to migrate printer mappings from UTILITY2012|UTILITY2012 to ICUPRTSVR01 for Windows 7 users
    
    .DESCRIPTION
        Logon Script to migrate printer mappings from UTILITY2012|UTILITY2012 to ICUPRTSVR01 for Windows 7 users
    
    .NOTES
        Author: Boe Prox
        Create: 09 NOV 2012
        Modified:
        Version 1.0 - Initial Script Creation
                1.1 Added Header Text for CSV file
#>
[cmdletbinding()]
Param (
    $newPrintServer = "ICUPRTSVR01"
)
<#
    #Header for CSV log file:
    "COMPUTERNAME,USERNAME,PRINTERNAME,RETURNCODE-ERRORMESSAGE,DATETIME,STATUS" | 
        Out-File -FilePath "\\ICUPRTSVR01\C$\PrintMigration\PrintMigration.csv" -Encoding ASCII
#>
Try {
    Write-Verbose ("{0}: Checking for printers mapped to old print server" -f $Env:USERNAME)
    $printers = @(Get-WmiObject -Class Win32_Printer -Filter "SystemName='\\\\UTILITY2012' OR SystemName='\\\\UTILITY2012'" -ErrorAction Stop)
    
    If ($printers.count -gt 0) {        
        ForEach ($printer in $printers) {
            Write-Verbose ("{0}: Replacing with new print server name: {1}" -f $Printer.Name,$newPrintServer)
            $newPrinter = $printer.Name -replace "UTILITY2012|UTILITY2012",$newPrintServer  
            $returnValue = ([wmiclass]"Win32_Printer").AddPrinterConnection($newPrinter).ReturnValue                
            If ($returnValue -eq 0) {
                If ($printer.Default) {
                    #If old printer was default, set new printer as default
                    $defaultPrinter = $newPrinter -replace "\\",'\\'
                    $createdPrinter = Get-WmiObject -Class Win32_Printer -Filter "Name='$defaultPrinter'"
                    $createdPrinter.SetDefaultPrinter() | Out-Null   
                }    
                "{0},{1},{2},{3},{4},{5}" -f $Env:COMPUTERNAME,
                                             $env:USERNAME,
                                             $newPrinter,
                                             $returnValue,
                                             (Get-Date),
                                             "Added Printer" | Out-File -FilePath "\\ICUPRTSVR01\c$\PrintMigration\PrintMigration.csv" -Append -Encoding ASCII            
                Write-Verbose ("{0}: Removing" -f $printer.name)
                $printer.Delete()
                "{0},{1},{2},{3},{4},{5}" -f $Env:COMPUTERNAME,
                                             $env:USERNAME,
                                             $printer.Name,
                                             $returnValue,
                                             (Get-Date),
                                             "Removed Printer" | Out-File -FilePath "\\ICUPRTSVR01\C$\printMigration\PrintMigration.csv" -Append -Encoding ASCII
            } Else {
                Write-Verbose ("{0} returned error code: {1}" -f $newPrinter,$returnValue)
                "{0},{1},{2},{3},{4},{5}" -f $Env:COMPUTERNAME,
                                             $env:USERNAME,
                                             $newPrinter,
                                             $returnValue,
                                             (Get-Date),
                                             "Error Adding Printer" | Out-File -FilePath "\\ICUPRTSVR01\C$\PrintMigration\PrintMigration.csv" -Append -Encoding ASCII
            }
        }
    }
} Catch {
    "{0},{1},{2},{3},{4},{5}" -f $Env:COMPUTERNAME,
                                 $env:USERNAME,
                                 "WMIERROR",
                                 $_.Exception.Message,
                                 (Get-Date),
                                 "Error Querying Printers" | Out-File -FilePath "\\ICUPRTSVR01\C$\PrintMigration\PrintMigration.csv" -Append -Encoding ASCII
}
Windows for business Windows Server User experience Print jobs
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-02-14T16:08:56.3833333+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    Migrating printers from one server to another can be a tricky process, as there are many factors that can affect the success of the migration. The script you found online may not be compatible with your environment or the server versions you are using.

    One way to migrate printers from one server to another is to use the Print Management Console in Windows. You can use this console to select the printers you want to migrate, and then export the settings to an .inf file. You can then import the file on the other server, and the printers will be automatically added.

    Alternatively, you can use a third-party tool to help with the migration. Printer Migrator is a tool designed to help with the migration of printers, and it supports the migration of printers between different server versions. It also provides detailed logging of the migration process, allowing you to troubleshoot any issues.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.