Transferring Windows Server roles to a new server, Part I DFS

New-Item “C:\Test Share” -ItemType directoryNew-SMBShare -Name “Test Share” -Path “C:\Test Share”Revoke-SMBShareAccess -Name “Test Share” -AccountName Everyone -ForceGrant-SMBShareAccess -Name “Test Share” -AccountName “test\Domain Admins” -AccessRight Full -ForceGrant-SMBShareAccess –Name “Test Share” -AccountName “test\Domain Users” -AccessRight Read -Force
Get-ACL “\\TestDC\Test Share” | Set-ACL “\\BackupDC3\Test Share”
(Get-ACL -Path “C:\Test Share”).Access | Format-Table -AutoSizeGet-SMBShareAccess -Name “Test Share”
#Prep a new folder for adding to an existing DFS namespace$NewServer = Read-Host “Please enter the computername of the new server. Example: BackupDC3”$NewDirPath = Read-Host “Please enter the new folder’s path on the new server. Example: C:\Test Share”$NewDirName = Read-Host “Please enter the new folder’s share name. Example: Test Share”$OldFolder = Read-Host “Please enter an existing DFS target folder to clone permissions. Example: \\TestDC\Test Share”New-Item $NewDirPath -itemtype directoryNew-SMBShare -Name $NewDirName -Path $NewDirPathRevoke-SMBShareAccess -Name “$NewDirName” -AccountName Everyone -ForceGrant-SMBShareAccess -Name $NewDirName -AccountName “test\Domain Admins” -AccessRight Full -ForceGrant-SMBShareAccess –Name $NewDirName -AccountName “test\Domain Users” -AccessRight Read -ForceGet-ACL $OldFolder | Set-ACL \\$NewServer\$NewDirName
Get-WindowsFeature *DFS*
Add-WindowsFeature -Name FS-DFS-Namespace, FS-DFS-Replication -IncludeManagementTools
New-DfsnFolderTarget -Path “\\test.local\Mishky’s Share\Test Share” -TargetPath “\\BackupDC3\Test Share” -ReferralPriorityClass SiteCostNormal
Get-DfsReplicationGroup -GroupName “test.local\Mishky’s Share\Test Share” | Get-DfsReplicatedFolder -FolderName “Test Share” | Add-DfsrMember -ComputerName BackupDC3Add-DfsrConnection -GroupName “test.local\Mishky’s Share\Test Share” -SourceComputerName TestDC -DestinationComputerName BackupDC3Set-DfsrMembership -GroupName “test.local\Mishky’s Share\Test Share” -FolderName “Test Share” -ComputerName BackupDC3 -ContentPath “C:\Test Share”
Get-DfsReplicationGroup -GroupName “test.local\Mishky’s Share\Test Share” | Get-DfsReplicatedFolder -FolderName “Test Share” | Get-DfsrMembership
Remove-DfsnFolderTarget -Path “\\test.local\Mishky’s Share\Test Share” -TargetPath \\TestDC\Test ShareGet-DfsReplicationGroup -GroupName “test.local\Mishky’s Share\Test Share” | Get-DfsReplicatedFolder -FolderName “Test Share” | Remove-DfsrMember -ComputerName TestDC
Set-DfsrMembership -GroupName “\\test.local\Mishky’s Share\Test Share” -FolderName “Test Share” -ComputerName BackupDC -ContentPath “C:\Test Share” -PrimaryMember $trueSet-DfsrMembership -GroupName “\\test.local\Mishky’s Share\Test Share” -FolderName “Test Share” -ComputerName TestDC -ContentPath “C:\Test Share”

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rich

Rich

15 Followers

I work various IT jobs & like Windows domain security as a hobby. Most of what’s here is my notes from work or the lab.