70-411DFSMicrosoftpowershellServer 2012R2

70-411 DFS and PowerShell


70-411 DFS and PowerShell by edgoad

#############################################
#Setup file shares
#Execute on Server1
New-Item C:Sales -Type directory
New-SmbShare -Name “Sales” -Path “C:Sales” -ReadAccess “Everyone”

#Execute on Server2
New-Item C:Marketing -Type directory
New-SmbShare -Name “Marketing” -Path “C:Marketing” -ReadAccess “Everyone”

#############################################
#Install DFS
Install-WindowsFeature “FS-DFS-Replication”, “FS-DFS-Namespace” -IncludeManagementTools
Install-WindowsFeature -Computername 411Server2-00 “FS-DFS-Replication” -IncludeManagementTools

#Setup DFS Namespace
New-Item C:DFSRootsCompany -Type directory
New-SmbShare -Name “Company” -Path “C:DFSRootsCompany” -ReadAccess “Everyone”
New-DfsnRoot -TargetPath “\411server1Company” -Type DomainV2 -Path “\411dom1-00.localCompany”
New-DfsnFolder -Path “\411dom1-00.localCompanySales” -TargetPath “\411Server1Sales”
New-DfsnFolder -Path “\411dom1-00.localCompanyMarketing” -TargetPath “\411Server2-00Marketing”

#############################################
#Execute on Server1
New-Item C:Accounting -Type directory
New-SmbShare -Name “Accounting” -Path “C:Accounting” -ReadAccess “Everyone”
New-Item “C:AccountingServer1.txt” -Type File

#Execute on Server2
New-Item C:Accounting -Type directory
New-SmbShare -Name “Accounting” -Path “C:Accounting” -ReadAccess “Everyone”
New-Item “C:AccountingServer2.txt” -Type File

#setup DFS Replication
New-DfsReplicationGroup -GroupName “Accounting Replication Group”
New-DfsReplicatedFolder -FolderName “Accounting” -GroupName “Accounting Replication Group”
Add-DfsrMember -ComputerName 411Server1, 411Server2-00 -GroupName “Accounting Replication Group”
Add-DfsrConnection -GroupName “Accounting Replication Group” -SourceComputerName 411Server1 -DestinationComputerName 411Server2-00
Set-DfsrMembership -GroupName “Accounting Replication Group” -FolderName “Accounting” -ContentPath “C:Accounting” -ComputerName 411Server1 -PrimaryMember $true -Force
Set-DfsrMembership -GroupName “Accounting Replication Group” -FolderName “Accounting” -ContentPath “C:Accounting” -ComputerName 411Server2-00  -Force

Leave a Reply