Virtual_Jas Posted February 24, 2014 Posted February 24, 2014 Hi all, Does anyone own a script that will migrate all printer's from one print server to another, whilst keeping their share names etc intact? Long story short, I am looking at decommissioning an old Windows Server 2003 box in favor of a new Server 2008 server. Thanks in advance! Jason
featured_spectre Posted February 24, 2014 Posted February 24, 2014 Powershell. Remember to change printer names and new share names. enjoy Clear-Host # This procedure adds a new printer Function InstallNewPrinter{ Param ([string]$currentPrinter, [string]$newPrinter) # Write-Host "CurrentPrinter : " $currentPrinter # Write-Host "New Printer : " $newPrinter # Write-Host "Is Printer Default : " $isDefault #Add new Printer $global:net.AddWindowsPrinterConnection($newPrinter) #Add current printer to the TobeDeleted List $global:PrintersTobeDeleted += $currentPrinter } # This procedure sets the respected new printer default Function SetPrinterDefault{ Param ([string]$defaultPrinter) #If current printer is default, make the new a default printer $global:net.SetDefaultPrinter($defaultPrinter) } # This procedure deletes all the old printer which were replaced by this script. Function DeleteCurrentPrinters{ foreach ($printerTodelete in $global:PrintersTobeDeleted) { $global:net.RemovePrinterConnection($printerTodelete) } } # Set print server name $Printserver = "." # This section will identify all the installed Network printer under logged in users profile using WMI $Printers = Get-WMIObject Win32_Printer -computername $Printserver -Filter "Network=True" # This is a blank array to store the installed Network printer under logged in users profile and pass it on $PrintersTobeDeleted = @() $newPrinter = "" $defaultPrinter = "" if($Printers) { # Get Network object $global:net = new-Object -com WScript.Network foreach ($Printer in $Printers) { # Write-Host "Name: " $Printer.Name # Write-Host "Location: " $Printer.Location # Write-Host "Comment: " $Printer.Comment # Write-Host "DriverName: " $Printer.DriverName # Write-Host "Shared: " $Printer.Shared # Write-Host "ShareName: " $Printer.ShareName # Just swap your old printer name with new server\printer name here switch ($Printer.ShareName) { "SV01Dispatch-M" {$newPrinter = "\\SRV-PSTREET01\SV-01-M7"} "SV01DriverRm-B" {$newPrinter = "\\SRV-PSTREET01\SV-01-M6"} "SV01Fleet-C" {$newPrinter = "\\SRV-PSTREET01\SV-01-C3"} "SV01Fleet-M" {$newPrinter = "\\SRV-PSTREET01\SV-01-M5"} "SV01QA-M" {$newPrinter = "\\SRV-PSTREET01\SV-01-M4"} "SV02BusFac-11x17" {$newPrinter = "\\SRV-PSTREET01\SV-02-C2"} "SV02BusFac-M" {$newPrinter = "\\SRV-PSTREET01\SV-02-M3"} "SV02BusFac-XR1" {$newPrinter = "\\SRV-PSTREET01\SV-02-X1"} "SV02BusOps-M" {$newPrinter = "\\SRV-PSTREET01\SV-02-M2"} "SV02EX-MH" {$newPrinter = "\\SRV-PSTREET01\SV-02-C1"} "SV02TrainRoom-M" {$newPrinter = "\\SRV-PSTREET01\SV-02-M1"} } if ($newPrinter -ne "") { if ($Printer.Default) {$defaultPrinter = $newPrinter} InstallNewPrinter $Printer.Name $newPrinter $newPrinter = "" } } SetPrinterDefault $defaultPrinter DeleteCurrentPrinters } 1
tmcd35 Posted February 24, 2014 Posted February 24, 2014 Or use the Printer Migration Tool: Print Migration Tool
Virtual_Jas Posted February 24, 2014 Author Posted February 24, 2014 Brill - Thanks for the quick response! So all I need to do with the above is change the following lines to reflect the old share names and the new server + printer name? "SV01Dispatch-M" {$newPrinter = "\\SRV-PSTREET01\SV-01-M7"} "SV01DriverRm-B" {$newPrinter = "\\SRV-PSTREET01\SV-01-M6"} "SV01Fleet-C" {$newPrinter = "\\SRV-PSTREET01\SV-01-C3"} "SV01Fleet-M" {$newPrinter = "\\SRV-PSTREET01\SV-01-M5"} "SV01QA-M" {$newPrinter = "\\SRV-PSTREET01\SV-01-M4"} "SV02BusFac-11x17" {$newPrinter = "\\SRV-PSTREET01\SV-02-C2"} "SV02BusFac-M" {$newPrinter = "\\SRV-PSTREET01\SV-02-M3"} "SV02BusFac-XR1" {$newPrinter = "\\SRV-PSTREET01\SV-02-X1"} "SV02BusOps-M" {$newPrinter = "\\SRV-PSTREET01\SV-02-M2"} "SV02EX-MH" {$newPrinter = "\\SRV-PSTREET01\SV-02-C1"} "SV02TrainRoom-M" {$newPrinter = "\\SRV-PSTREET01\SV-02-M1"}
featured_spectre Posted February 24, 2014 Posted February 24, 2014 Yes. If it fails, let me know, and what line, I will look into it, however if it does, use the migration tool above.
Virtual_Jas Posted February 24, 2014 Author Posted February 24, 2014 Brill, thanks! Is there a way of leaving the old printers on the server after the script has run just in case?
FN-GM Posted February 24, 2014 Posted February 24, 2014 I am moving from x86 to x64. You will need to make sure all the printers on the 2003 box have x64 drivers installed before you migrate
featured_spectre Posted February 24, 2014 Posted February 24, 2014 I've not needed to keep the printers on the machine I am migrating from. So haven't bothered adding in a keep the printers section. Sorry!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now