+ Post New Thread
Results 1 to 10 of 10
Scripts Thread, Migrate printers from one server to another - PowerShell or VBS? in Coding and Web Development; Hi all, Does anyone own a script that will migrate all printer's from one print server to another, whilst keeping ...
  1. #1
    Virtual_Jas's Avatar
    Join Date
    Jun 2009
    Location
    Oxford, Oxfordshire
    Posts
    23
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Migrate printers from one server to another - PowerShell or VBS?

    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

  2. #2

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    12,080
    Thank Post
    1,637
    Thanked 1,956 Times in 1,431 Posts
    Blog Entries
    2
    Rep Power
    440
    Powershell. Remember to change printer names and new share names. enjoy

    Code:
    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 
    }

  3. Thanks to nephilim from:

    Virtual_Jas (24th February 2014)

  4. #3

    tmcd35's Avatar
    Join Date
    Jul 2005
    Location
    Norfolk
    Posts
    5,713
    Thank Post
    858
    Thanked 904 Times in 749 Posts
    Blog Entries
    9
    Rep Power
    330
    Or use the Printer Migration Tool: Print Migration Tool

  5. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,054
    Thank Post
    888
    Thanked 1,729 Times in 1,492 Posts
    Blog Entries
    12
    Rep Power
    454
    Are you moving from x86 to x64 ?

  6. #5
    Virtual_Jas's Avatar
    Join Date
    Jun 2009
    Location
    Oxford, Oxfordshire
    Posts
    23
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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"}

  7. #6
    Virtual_Jas's Avatar
    Join Date
    Jun 2009
    Location
    Oxford, Oxfordshire
    Posts
    23
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    I am moving from x86 to x64.

  8. #7

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    12,080
    Thank Post
    1,637
    Thanked 1,956 Times in 1,431 Posts
    Blog Entries
    2
    Rep Power
    440
    Yes. If it fails, let me know, and what line, I will look into it, however if it does, use the migration tool above.

  9. #8
    Virtual_Jas's Avatar
    Join Date
    Jun 2009
    Location
    Oxford, Oxfordshire
    Posts
    23
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Brill, thanks!

    Is there a way of leaving the old printers on the server after the script has run just in case?

  10. #9

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,054
    Thank Post
    888
    Thanked 1,729 Times in 1,492 Posts
    Blog Entries
    12
    Rep Power
    454
    Quote Originally Posted by Virtual_Jas View Post
    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

  11. #10

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    12,080
    Thank Post
    1,637
    Thanked 1,956 Times in 1,431 Posts
    Blog Entries
    2
    Rep Power
    440
    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!

SHARE:
+ Post New Thread

Similar Threads

  1. moving printer from 2008r2 server to another 2008r2 server using GPO
    By edutech4schools in forum Windows Server 2008 R2
    Replies: 1
    Last Post: 13th March 2012, 01:10 PM
  2. Moving User areas from one server to another
    By sarchs in forum Windows Server 2000/2003
    Replies: 7
    Last Post: 17th May 2010, 12:33 PM
  3. move Sophos enterprise console from one server to another
    By sacrej in forum How do you do....it?
    Replies: 3
    Last Post: 16th April 2010, 02:53 PM
  4. Checklist? Moving from one server to another
    By contink in forum Windows Server 2000/2003
    Replies: 6
    Last Post: 7th July 2009, 12:32 PM
  5. Replies: 1
    Last Post: 15th October 2007, 07:44 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •