Monday, April 17, 2017

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:\DFSRoots\Company -Type directory
New-SmbShare -Name "Company" -Path "C:\DFSRoots\Company" -ReadAccess "Everyone"
New-DfsnRoot -TargetPath "\\411server1\Company" -Type DomainV2 -Path "\\411dom1-00.local\Company"
New-DfsnFolder -Path "\\411dom1-00.local\Company\Sales" -TargetPath "\\411Server1\Sales"
New-DfsnFolder -Path "\\411dom1-00.local\Company\Marketing" -TargetPath "\\411Server2-00\Marketing"

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

#Execute on Server2
New-Item C:\Accounting -Type directory
New-SmbShare -Name "Accounting" -Path "C:\Accounting" -ReadAccess "Everyone"
New-Item "C:\Accounting\Server2.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


No comments: