Skip to content
Back to Blog
Windows Server

Windows File Server with DFS: Distributed File System Setup

Configure Windows DFS Namespaces and DFS Replication for distributed file sharing, redundancy, and branch office file access.

Oct 2025
11 min read

Introduction

Windows Server DFS (Distributed File System) provides a unified namespace for file shares across multiple servers, plus replication between sites. Without DFS, users in a branch office must access files across a slow WAN link. With DFS Replication, each site has a local copy of shared folders that stays synchronized. This guide covers DFS Namespaces and DFS Replication for enterprise deployments.

DFS Namespaces

DFS Namespaces create a virtual folder structure that maps to real shares:

TEXT
Without DFS:
server1documents    (IT must tell users which server)
server2projects

With DFS Namespace:
company.localshareddocuments   → maps to server1documents
company.localsharedprojects    → maps to server2projects
(Users only need to know ONE path)
POWERSHELL
# Install DFS features
Install-WindowsFeature FS-DFS-Namespace, FS-DFS-Replication -IncludeManagementTools

# Create DFS Namespace (Domain-based is recommended)
New-DfsnRoot `
  -Path "company.localshared" `
  -Type DomainV2 `
  -TargetPath "ileserver01dfsroot" `
  -Description "Company shared files"

# Add folders to namespace
New-DfsnFolder `
  -Path "company.localshareddocuments" `
  -TargetPath "ileserver01documents"

New-DfsnFolder `
  -Path "company.localsharedprojects" `
  -TargetPath "ileserver02projects"

# Add redundant targets (automatic failover)
New-DfsnFolderTarget `
  -Path "company.localshareddocuments" `
  -TargetPath "ileserver02documents"  # Second copy at another server

DFS Replication

POWERSHELL
# Create replication group
New-DfsReplicationGroup -GroupName "SharedDocuments"

# Add members (servers that will replicate)
Add-DfsrMember -GroupName "SharedDocuments" -ComputerName "fileserver01"
Add-DfsrMember -GroupName "SharedDocuments" -ComputerName "fileserver02"

# Add replicated folder
Add-DfsrReplicatedFolder `
  -GroupName "SharedDocuments" `
  -FolderName "Documents" `
  -DfsnPath "company.localshareddocuments"

# Configure folder path on each member
Set-DfsrMembership `
  -GroupName "SharedDocuments" `
  -FolderName "Documents" `
  -ComputerName "fileserver01" `
  -ContentPath "D:SharesDocuments" `
  -PrimaryMember $true  # Primary owns initial sync

Set-DfsrMembership `
  -GroupName "SharedDocuments" `
  -FolderName "Documents" `
  -ComputerName "fileserver02" `
  -ContentPath "D:SharesDocuments" `
  -PrimaryMember $false

# Set replication topology (full mesh or hub-and-spoke)
Add-DfsrConnection `
  -GroupName "SharedDocuments" `
  -SourceComputerName "fileserver01" `
  -DestinationComputerName "fileserver02"

Monitoring DFS Replication

POWERSHELL
# Check replication backlog (how many files waiting to sync)
Get-DfsrBacklog `
  -GroupName "SharedDocuments" `
  -FolderName "Documents" `
  -SourceComputerName "fileserver01" `
  -DestinationComputerName "fileserver02" `
  -Verbose

# Get replication state
Get-DfsReplicatedFolder -GroupName "SharedDocuments"

# Check replication partner status
Get-DfsrConnection -GroupName "SharedDocuments"

# DFS Replication health report
Get-DfsrMembership -GroupName "SharedDocuments" |
  Select-Object ComputerName, FolderName, LastSyncTime, State

File Server Permissions

POWERSHELL
# Create share with proper permissions
New-SmbShare `
  -Name "Documents" `
  -Path "D:SharesDocuments" `
  -FullAccess "COMPANYFileAdmins" `
  -ChangeAccess "COMPANYDomain Users" `
  -ReadAccess "COMPANYContractors" `
  -Description "Shared documents"

# NTFS permissions (more granular)
$acl = Get-Acl "D:SharesDocuments"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
    "COMPANYHRTeam",
    "FullControl",
    "ContainerInherit,ObjectInherit",
    "None",
    "Allow"
)
$acl.AddAccessRule($rule)
Set-Acl "D:SharesDocumentsHR" $acl

# Enable Access-Based Enumeration (users only see folders they can access)
Set-SmbShare -Name "Documents" -FolderEnumerationMode AccessBased

Shadow Copies (Previous Versions)

POWERSHELL
# Enable shadow copies on volume
$job = Register-WmiObject -Namespace rootcimv2 `
  -Class Win32_ShadowCopy

# Using vssadmin
vssadmin add shadowstorage /For=D: /On=D: /MaxSize=10%
vssadmin create shadow /For=D:

# Schedule shadow copies via Task Scheduler
# Or use: Set-ItemProperty on Windows Server
# Typically done via GUI: Computer Management → Shared Folders →
# Right-click volume → Configure Shadow Copies

# List shadow copies
vssadmin list shadows /For=D:

File Server Troubleshooting

POWERSHELL
# Check who has files open
Get-SmbOpenFile | Where-Object {$_.ShareName -eq "Documents"}

# Force close open file
Close-SmbOpenFile -FileId 12345678 -Force

# Check share permissions
Get-SmbShareAccess -Name "Documents"

# Test DFS path resolution
dfsutil target company.localshareddocuments

# DFS namespace health
dfsdiag /testdcs /domain:company.local
dfsdiag /testnamespace /root:company.localshared /recurse /full

# Fix DFS replication conflict folder
# Conflicts stored in: D:SharesDocumentsDfsrPrivateConflictAndDeletedGet-ChildItem "D:SharesDocumentsDfsrPrivateConflictAndDeleted" |
  Select-Object Name, LastWriteTime, Length

DFS Namespaces and Replication are essential for multi-site file sharing. The key insight: DFS Namespace gives users a consistent path regardless of where files actually live, while DFS Replication keeps those files synchronized — together they provide both high availability and geographic distribution of files.