Migrate Shares and Share Permissions To A New Server
Scenario:
Customer is replacing a file server with new hardware. The existing shares need to be migrated to the new server. There are far too many share permissions to document and duplicate without incurring significant cost to the customer.
Solution:
1. First use ROBOCOPY to copy the data with the required NTFS permissions. This is accomplished using the /E /SEC /COPYALL switches. Ideally the data will exist on the same drive letter on the new server as the old one, but it does not have to.
2. Open Regedit and navigate to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Services\LanmanServer\Shares
3. Export the key and save the export to a safe location.
4. In the right pane you will see a list of all the current shares. If the server drive letters and paths are the same, proceed to step 5. Otherwise double click each share name and alter the path in the pop up window to point to where the share will exist on the new server.
5. Delete any shares listed that will not exist on the new server.
6. Export the Shares key and copy the exported file to the new server.
7. Import the registry key on the new server by double clicking the file or choose File, Import from within Regedit.
8. Reboot the server. The shares and permission will be automatically recreated.
Bonus:
If the shares are user shares that match the user name and you wish to reset permissions to allow System and Domain Admins and the user to only have access to their share, you can do so via script.
‘==========================================================================
‘
‘ NAME: ResetNTFSUserPerms.vbs
‘
‘ AUTHOR: Mark D. MacLachlan , The Spider’s Parlor
‘ URL: http://www.TheSpidersParlor.com
‘ COPYRIGHT (c) 2005 All Rights Reserved
‘ DATE : 1/22/2009
‘
‘ THIS CODE AND INFORMATION IS PROVIDED “AS IS” WITHOUT WARRANTY OF
‘ ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
‘ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
‘ PARTICULAR PURPOSE.
‘
‘ IN NO EVENT SHALL THE SPIDER’S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS
‘ BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
‘ DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
‘ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
‘ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
‘ OF THIS CODE OR INFORMATION.
‘
‘ COMMENT: Download xcacls.vbs from Microsoft.com.
‘
‘==========================================================================
Dim objFSO, oShell, oFolder, colSubfolders, oSubFolder, sXPath, sFolder, sys, DomainName
sXpath = “C:\Utilities\xcacls.vbs”
sDrive = “D:\Users\FolderRedirections\”
Set objFSO = createobject(”Scripting.FileSystemObject”)
Set oShell = Wscript.CreateObject(”Wscript.Shell”)
Set oFolder = objFSO.GetFolder(sDrive)
Set colSubfolders = oFolder.Subfolders
Set sys = CreateObject(”ADSystemInfo”)
DomainName = sys.DomainShortName
For Each oSubfolder in colSubfolders
sFolder = objFso.GetFolder(oSubfolder).ShortPath & ” ”
oShell.Run “cmd /c cscript.exe ” & sXpath & ” “& sFolder & ” ” & _
” /I Remove /G “&Chr(34)& “System” & Chr(34)& “:F”
WScript.Sleep 2000
oShell.Run “cmd /c cscript.exe ” & sXpath & ” “& sFolder & ” ” & _
” /E /G “&Chr(34)& “Domain Admins” &Chr(34)& “:F”
WScript.Sleep 2000
oShell.Run “cmd /c cscript.exe ” & sXpath & ” “& sFolder & ” ” & _
” /E /G ” & DomainName &”\” & oSubfolder.Name & “:F”
Next
