Windows 2012 R2 -- copying NETWORK shares ?

I am going to use ROBOCOPY to copy all my
old 2003 Server's C, D, E, F, G, H, Q, R, S
drive files to the same drive letters on my
new 2012 Server, but this will not copy the
associated 40+ "SHARES"

Please post some good articles on how to
export the Shares from the registry on the
source 2003 server and import them into the
registry on the destination 2012 server or
let me know what you recommend.
finance_teacherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guillermo Rodrigo GilConsultorCommented:
Hi.
You can read the next link https://support.microsoft.com/en-us/kb/125996
This link explain how to move share's between files server.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lee W, MVPTechnology and Business Process AdvisorCommented:
You're not virtualizing?  You should be!  If you virtualized, then rather than Robocopy, just use Disk2VHD to capture each drive (ONE VHD PER DRIVE LETTER).  Then attach each VHD to the VM.  Assign drive letters.  Export the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares and import and reboot.  done.
0
Jose TorresSenior SQL Server DBACommented:
We faced an issue where during DR exercises we needed to recreate the shares and permissions as well.
We created a 2 powershell scripts.  One will export the shares and permissions to a csv file the other will import the shares and permissions from the csv file.

This is the code for the export change backup location to suit your needs
# change to the servername to be used. (currently set to get local computer name)
$ServerName = $Env:COMPUTERNAME

# get the current timestamp
$Date = Get-Date -Uformat '%Y%m%d%H%M%S'
# setup the filename
$FileName = 'C:\DisasterRecovery\Backup_Shares\Backups\' + 'Backup_' + $ServerName + '_ShareInfo_' + $Date + '.csv' 

# get Shares (Type o is "Normal" shares) 
$Shares = Get-WmiObject Win32_Share -ComputerName $ServerName -Filter 'type=0' 

# combine Shares with Security info 
$ShareInfo = @() 
Foreach ($share IN $Shares) { 
	$shareSec = Get-WmiObject Win32_LogicalShareSecuritySetting -ComputerName $ServerName -Filter "name='$($share.name)'" 
  	IF($shareSec) { 
    	$sd = $shareSec.invokeMethod('GetSecurityDescriptor',$null,$null) 
    	$ShareInfo += $sd.Descriptor.DACL |% { 
      		$_ | select @{e={$share.name};n='Name'}, 
        	@{e={$share.Path};n='Path'}, 
        	@{e={$share.Description};n='Description'}, 
        	AccessMask, 
        	AceFlags, 
        	AceType, 
        	@{e={$_.trustee.Name};n='User'}, 
        	@{e={$_.trustee.Domain};n='Domain'}, 
        	@{e={$_.trustee.SIDString};n='SID'} 
    	} 
  	}ELSE{ 
		$ShareInfo += $share | select Name,Path,Description 
  	} 
}  

# Export the shares to CSV 
$ShareInfo | select Name,Path,Description,User,Domain,SID, 
  AccessMask,AceFlags,AceType | export-csv -noType $filename

Open in new window

This is the code for the Import. I run this from a batch file so you will need to modify the $fname and remove the param section of the script. Also change the filename path accordingly.
# get argument passed by cmd
Param(
	[Parameter(Mandatory=$true)] [string] $fname,
	[Parameter(ValueFromRemainingArguments=$true)] $args
)
# check if more than 1 argument was passed
if ($args) {
	Write-Host "ERROR: Unknown argument(s): $args"
	Exit 2
}
# set filename and path
$FileName = 'C:\DisasterRecovery\Backup_Shares\Backups\' + $fname
# check if file exists
if (!(Test-Path $FileName)) {
	Write-Host "ERROR: File $FileName does not exist."
	Exit 3
}

# PROCESSING BRANCHES TO LINE 87

############################
# Functions used in script #
############################

Function Modify-WMIShareACL([string]$ServerName, [string]$ShareName, $ace){
    $wPrivilege = Get-WmiObject Win32_LogicalShareSecuritySetting -ComputerName $ServerName -filter "name='$ShareName'" 
    $wPrivilege.psbase.Scope.Options.EnablePrivileges = $true 
    $oldDACL = ($wPrivilege.GetSecurityDescriptor()).Descriptor.DACL 
    $sd = ([WMIClass] ("\\" + $ServerName + "\root\CIMv2:Win32_SecurityDescriptor")).CreateInstance()     
    $sd.DACL = $oldDACL #copy
    $sd.DACL += @($ace.psobject.baseobject) # append
    $sd.ControlFlags="0x4" # set SE_DACL_PRESENT flag 
    $wPrivilege.SetSecurityDescriptor($sd)
}

Function Create-WMITrustee ([string]$ServerName, [string]$ShareUser, [string]$ShareSID){
	$sid = New-Object Security.Principal.SecurityIdentifier($ShareSID)
	[byte[]]$ba = ,0 * $sid.BinaryLength     
    [void]$sid.GetBinaryForm($ba,0) 

	$Trustee = ([WMIClass] ("\\" + $ServerName + "\root\CIMv2:Win32_Trustee")).CreateInstance() 
    $Trustee.SID = $ba
    $Trustee
}

Function Create-WMIAce ([string]$ServerName, [string]$ShareUser, [string]$ShareSID, [string]$ShareAccessMask, [string]$ShareAceFlags, [string]$ShareAceType){
	$Trustee = Create-WMITrustee $ServerName $ShareUser $ShareSID
	$ace = ([WMIClass] ("\\" + $ServerName + "\root\CIMv2:Win32_ACE")).CreateInstance() 
	$ace.AccessMask = $ShareAccessMask
	$ace.AceFlags = $ShareAceFlags
	$ace.AceType = $ShareAceType
	$ace.Trustee = $Trustee
	$ace
}

##########################
# PROCESSING RESUMES     #
##########################

# change to the servername to be used. (currently set to get local computer name)
$ServerName = $Env:COMPUTERNAME

# Import the CSV file 
$ShareList = Import-Csv $FileName 

# CREATE SHARES

# get the unique shares 
$UniqueShares = $ShareList | select -Unique name, Path, Description
# go thru each unique share
Foreach ($ushare in $UniqueShares) {
	$ShareName = $ushare.name
	$SharePath = $ushare.Path
	$ShareDesc = $ushare.Description
	# check if path exists
	if (!(Test-Path $SharePath)) {
		Write-Host "ERROR: Path $SharePath DOES NOT EXIST"
		Exit 5
	}
	# create share if it does not exist
	if (!(Get-WmiObject Win32_Share -ComputerName $ServerName | Where-Object -FilterScript {$_.Name -eq $ShareName})) {
		# create pointer to Win32_Share
		[WMIClass]$cshare = "\\$ServerName\root\CIMv2:Win32_Share"
		# create share
		$rc = $cshare.Create($SharePath, $ShareName, 0, 0, $ShareDesc)
		# get description or rc value
		Switch ($rc.returnvalue){
			0  {$rvalue = "Success"}
			2  {$rvalue = "Access Denied"}
			8  {$rvalue = "Unknown Failure"}
			9  {$rvalue = "Invalid Name"}
			10 {$rvalue = "Invalid Level"}
			21 {$rvalue = "Invalid Parameter"}
			22 {$rvalue = "Duplicate Share"}
			23 {$rvalue = "Redirected Path"}
			24 {$rvalue = "Unknown Device or Directory"}
			25 {$rvalue = "Net Name Not Found"}
		}
		# check return value of create
		if ($rc.returnvalue -ne 0){
			Write-Host ("ERROR: Failed to create share {0} for {1} on {2}. Error: {3}" -f $ShareName, $SharePath, $ServerName, $rvalue)
			Exit 6
		}
	}
}
	
# CREATE SHARE PERMISSIONS

Foreach ($record in $ShareList) {
	$ShareName = $record.Name
	$SharePath = $record.Path
	$ShareDesc = $record.Description
	$ShareUser = $record.User
	$ShareDomain = $record.Domain
	$ShareSID = $record.SID
	$ShareAccessMask = $record.AccessMask
	$ShareAceFlags = $record.AceFlags
	$ShareAceType = $record.AceType
	$ace = Create-WMIAce $ServerName $ShareUser $ShareSID $ShareAccessMask $ShareAceFlags $ShareAceType
	Modify-WMIShareACL $ServerName $ShareName $ace

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2012

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.