2

We are in the progress of migrating to a new file and print server that has a different name to the old server. we have a lot of mapped drives based on departments as well as a lot of printers. I was just wondering what would be (in your opinion) the best way to change all references to the old server to the new one on the clients machine?

Thanks.

1 Answers1

4

To change mapped drive references, you could write a very simply VBScript that would remap these, and execute it as a logon script. Same for the printers.

I would then create a CNAME record on your DNS server pointing oldFileServer to newFileServer (just in case)

EDIT: You don't change the CNAME. 1) Start up new server. 2) Switch off old server 3) Delete DNS A record for oldFileServer.myDomain.loc 4) Add CNAME record pointing oldFileServer.myDomain.loc to newFileServer.myDomain.loc

As for a sample script, here's one a colleague put together when we migrated our 15 print servers. Just replace the \\oldPrintServer bit, the \\oldPrintServer.myDomain.loc bit, and \\newPrintServer bit. You would then need to call this as a logon script for the user (either via the User Account in AD, from an existing logon script, or via GPO)

Option Explicit
On Error Resume Next

MigratePrint("\\oldPrintServer")
MigratePrint("\\oldPrintServer.myDomain.loc")

Function MigratePrint(strOldServer)

Dim strComputer
Dim strShareName
Dim objWMIService
Dim objPrinter
Dim objItem
Dim colItems
Dim WshNetwork
Dim strNewServer

strComputer = "."
strNewServer="\\newPrintServer"

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Printer",,48)

For Each objItem in colItems
    If objItem.ServerName = strOldServer Then   
        If objItem.Default = "True" Then
            strShareName = objItem.ShareName
        End If
        WshNetwork.RemovePrinterConnection objItem.ServerName & "\" & objItem.ShareName, True, True
        WshNetwork.AddWindowsPrinterConnection strNewServer & "\" &  objItem.Sharename
    End If
Next

Set objPrinter = CreateObject("WScript.Network") 
objPrinter.SetDefaultPrinter (strNewServer & "\" & strShareName)


End Function
Izzy
  • 8,224
  • 2
  • 31
  • 35
  • You dont happen to have an example do you (of the VB script that is) In our testing when we changed the CNAME when you try to open a network share/mapped drive it comes back with "the local device name is already in use" thanks for your help. – philosoraptor Oct 24 '09 at 05:10
  • Thanks so much that worked perfectly, just need to work out how to do it for mapped drives now. – philosoraptor Oct 24 '09 at 06:05
  • I'm not going to write it for you, but using these three resources, you should be able to piece together the script (using the same logic as the print server one): http://blogs.technet.com/heyscriptingguy/archive/2005/10/27/how-can-i-determine-which-drives-are-mapped-to-network-shares.aspx http://msdn.microsoft.com/en-us/library/aa394173(VS.85).aspx http://blogs.technet.com/heyscriptingguy/archive/2006/11/13/how-can-i-map-a-drive-copy-a-file-to-that-drive-and-then-unmap-the-drive.aspx – Izzy Oct 24 '09 at 06:29
  • 1
    +1 Just for correctly guessing the OS with so little to go on. – John Gardeniers Oct 24 '09 at 07:23