diff --git a/DFS replication/dfsreplication.ps1 b/DFS replication/dfsreplication.ps1 new file mode 100644 index 0000000..187d7f1 --- /dev/null +++ b/DFS replication/dfsreplication.ps1 @@ -0,0 +1,86 @@ +# Check if DFSN module is installed +Get-Module -ListAvailable -Name DFSN + +# Check if DFSR module is installed +Get-Module -ListAvailable -Name DFSR + +# If not installed, install the modules (requires admin privileges) +Add-WindowsFeature -Name RSAT-DFS-Mgmt-Con + + +# Create a new replication group +New-DfsReplicationGroup -GroupName "FileServerGroup" -Description "Replication between SRV1 and DC1" + + +# Add both servers to the replication group +Add-DfsrMember -GroupName "FileServerGroup" -ComputerName "SRV1" +Add-DfsrMember -GroupName "FileServerGroup" -ComputerName "DC1" + + +# Create replication folders for each shared directory +$folders = @("finance", "sales", "hr", "it", "consultants") + +foreach ($folder in $folders) { + # Create the replicated folder + New-DfsReplicatedFolder -GroupName "FileServerGroup" ` + -FolderName $folder ` + -DfsnPath "\\rohanit\files\$folder" + + # Set up replication members for the folder + Set-DfsrMembership -GroupName "FileServerGroup" ` + -FolderName $folder ` + -ContentPath "c:\shares\$folder" ` + -ComputerName "SRV1" ` + -PrimaryMember $true + + Set-DfsrMembership -GroupName "FileServerGroup" ` + -FolderName $folder ` + -ContentPath "c:\dfsroots\$folder" ` + -ComputerName "DC1" ` + -PrimaryMember $false +} + + +# Set up bidirectional replication between servers +Add-DfsrConnection -GroupName "FileServerGroup" ` + -SourceComputerName "SRV1" ` + -DestinationComputerName "DC1" + + + # Check replication group status +Get-DfsReplicationGroup -GroupName "FileServerGroup" | Format-List + +# Check connection status +Get-DfsrConnection -GroupName "FileServerGroup" + +# Check folder configuration +Get-DfsReplicatedFolder -GroupName "FileServerGroup" + + + +# View replication backlog +Get-DfsrBacklog -GroupName "FileServerGroup" ` + -SourceComputerName "SRV1" ` + -DestinationComputerName "DC1" ` + -FolderName "finance" + +# Check replication health +Write-DfsrHealth -SourceComputerName "SRV1" -DestinationComputerName "DC1" + + + +# Reset replication if needed +Update-DfsrConfigurationFromAD -ComputerName "SRV1" +Update-DfsrConfigurationFromAD -ComputerName "DC1" + +# Check DFS service status +Get-Service DFSR -ComputerName "SRV1" +Get-Service DFSR -ComputerName "DC1" + + + +Get-Help *dfsr* +Get-Help Add-DfsrConnection -Detailed + + + diff --git a/DFS replication/dfssetup1.ps1 b/DFS replication/dfssetup1.ps1 new file mode 100644 index 0000000..21675e5 --- /dev/null +++ b/DFS replication/dfssetup1.ps1 @@ -0,0 +1,29 @@ +$session = New-PSSession -ComputerName "DC1" + +Invoke-Command -Session $session -ScriptBlock { + Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication -IncludeManagementTools +} + + +Invoke-Command -Session $session -ScriptBlock { + $basePath = "C:\DFSRoots" + $folders = @('Finance', 'Sales', 'IT', 'Consultants', 'HR') + + # Create base directory + New-Item -Path $basePath -ItemType Directory -Force + + # Create individual folders + foreach ($folder in $folders) { + New-Item -Path "$basePath\$folder" -ItemType Directory -Force + + } +} + +Invoke-Command -Session $session -ScriptBlock { + $folders = @('Finance', 'Sales', 'IT', 'Consultants', 'HR') + foreach ($folder in $folders) { + New-SmbShare -Name $folder -Path "C:\DFSRoots\$folder" -FullAccess "Everyone" + # Adjust share permissions according to your security requirements + } +} + diff --git a/lectures/dcst1005 b/lectures/dcst1005 new file mode 160000 index 0000000..24ab8d4 --- /dev/null +++ b/lectures/dcst1005 @@ -0,0 +1 @@ +Subproject commit 24ab8d4c98d63329bed5e55a462b0c6d1ba2776d