DFS Replication Storage Optimization: ConflictAndDeleted Quota Management and Disk Space Recovery
Distributed File System Replication (DFSR) maintains conflict resolution and deleted file storage that can consume significant disk space over time. This comprehensive guide covers DFSR storage optimization, ConflictAndDeleted quota management, and production-ready disk space recovery procedures for enterprise file servers.
DFSR Storage Architecture
ConflictAndDeleted Folder Purpose
# DFSR conflict resolution storage locations
C:\Windows\SYSVOL\domain\DfsrPrivate\ConflictAndDeleted\ # SYSVOL
E:\Shares\Data\DfsrPrivate\ConflictAndDeleted\ # Data shares
# Files stored in ConflictAndDeleted:
# 1. Conflicting file versions (simultaneous edits on multiple servers)
# 2. Deleted files (tombstoned for replication propagation)
# 3. Files replaced during replication recovery
# Default quota: 660 MB per replicated folder
# Files retained for 30 days by default
Identifying Storage Issues
# Check System Volume Information folder size
Get-ChildItem "C:\System Volume Information" -Force -Recurse | Measure-Object -Property Length -Sum | Select-Object @{Name="Size(GB)";Expression={[math]::Round($_.Sum/1GB,2)}}
# Check DFSR private folder size
Get-ChildItem "C:\Windows\SYSVOL\domain\DfsrPrivate" -Force -Recurse | Measure-Object -Property Length -Sum | Select-Object @{Name="Size(GB)";Expression={[math]::Round($_.Sum/1GB,2)}}
# List largest files in ConflictAndDeleted
Get-ChildItem "C:\Windows\SYSVOL\domain\DfsrPrivate\ConflictAndDeleted" -Force -Recurse |
Sort-Object Length -Descending |
Select-Object -First 20 FullName, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}}
# Check current ConflictAndDeleted quota
Get-DfsrMembership | Select-Object GroupName, FolderName, ConflictAndDeletedQuotaInMB
# View DFSR event logs for storage warnings
Get-WinEvent -FilterHashtable @{LogName='DFS Replication';Level=2,3} -MaxEvents 50 |
Where-Object {$_.Message -like "*quota*" -or $_.Message -like "*disk*"}
Quota Management
Adjusting ConflictAndDeleted Quota
# View current quota settings
Get-DfsrMembership | Format-Table GroupName, FolderName, ConflictAndDeletedQuotaInMB -AutoSize
# Reduce quota to reclaim space immediately
# WARNING: Files exceeding new quota will be deleted
Get-DfsrMembership |
Where-Object {$_.GroupName -eq "Domain System Volume"} |
Set-DfsrMembership -ConflictAndDeletedQuotaInMB 100
# Set quota for specific replicated folder
Set-DfsrMembership -GroupName "Data Replication Group" -FolderName "Public" -ConflictAndDeletedQuotaInMB 500
# Set quota for all replicated folders
Get-DfsrMembership | Set-DfsrMembership -ConflictAndDeletedQuotaInMB 200
# Verify new quota settings
Get-DfsrMembership | Format-Table GroupName, FolderName, ConflictAndDeletedQuotaInMB -AutoSize
Staging Folder Optimization
# Check staging folder quota (separate from ConflictAndDeleted)
Get-DfsrMembership | Select-Object GroupName, FolderName, StagingPathQuotaInMB
# Staging folder sizing recommendation:
# Minimum: 16 times the size of largest file
# Default: 4096 MB
# Production recommendation: Size of 16 largest files combined
# Identify largest files in replicated folder
$replicatedPath = "E:\Shares\Data"
Get-ChildItem $replicatedPath -Recurse -File |
Sort-Object Length -Descending |
Select-Object -First 16 Name, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}}
# Calculate recommended staging quota
$largestFiles = Get-ChildItem $replicatedPath -Recurse -File |
Sort-Object Length -Descending |
Select-Object -First 16
$totalSizeMB = ($largestFiles | Measure-Object -Property Length -Sum).Sum / 1MB
$recommendedQuota = [math]::Ceiling($totalSizeMB)
Write-Host "Recommended Staging Quota: $recommendedQuota MB" -ForegroundColor Cyan
# Set staging quota
Set-DfsrMembership -GroupName "Data Replication Group" -FolderName "Public" -StagingPathQuotaInMB $recommendedQuota
WMI-Based Cleanup
Using WMI for Immediate Cleanup
# Get Replicated Folder GUID
$replGroupName = "Domain System Volume"
$replFolderName = "SYSVOL Share"
# Method 1: Using Get-DfsrMembership
$membership = Get-DfsrMembership -GroupName $replGroupName -FolderName $replFolderName
$replicatedFolderGuid = $membership.Identifier
Write-Host "Replicated Folder GUID: $replicatedFolderGuid" -ForegroundColor Green
# Method 2: Using WMIC (alternative)
wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderconfig get replicatedfolderguid,replicatedfoldername
# Clean ConflictAndDeleted folder using WMI
$wmiCommand = @"
wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo where "replicatedfolderguid='$replicatedFolderGuid'" call cleanupconflictdirectory
"@
Invoke-Expression $wmiCommand
# Expected output:
# Method execution successful.
# Out Parameters:
# instance of __PARAMETERS
# {
# ReturnValue = 0;
# };
# Verify cleanup
Start-Sleep -Seconds 30
Get-ChildItem "C:\Windows\SYSVOL\domain\DfsrPrivate\ConflictAndDeleted" -Force | Measure-Object
Automated Cleanup Script
# Clean-DfsrConflictAndDeleted.ps1
param(
[string]$GroupName = "Domain System Volume",
[string]$FolderName = "SYSVOL Share",
[int]$NewQuotaMB = 100
)
# Get replicated folder GUID
$membership = Get-DfsrMembership -GroupName $GroupName -FolderName $FolderName
$guid = $membership.Identifier
Write-Host "Cleaning DFSR ConflictAndDeleted for: $GroupName\$FolderName" -ForegroundColor Yellow
Write-Host "Replicated Folder GUID: $guid" -ForegroundColor Cyan
# Lower quota temporarily to force cleanup
Write-Host "Setting quota to $NewQuotaMB MB..." -ForegroundColor Cyan
Set-DfsrMembership -GroupName $GroupName -FolderName $FolderName -ConflictAndDeletedQuotaInMB $NewQuotaMB
# Wait for quota change to process
Start-Sleep -Seconds 10
# Execute WMI cleanup
Write-Host "Executing WMI cleanup..." -ForegroundColor Cyan
$result = wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo where "replicatedfolderguid='$guid'" call cleanupconflictdirectory
if ($result -match "ReturnValue = 0") {
Write-Host "Cleanup completed successfully!" -ForegroundColor Green
} else {
Write-Host "Cleanup may have encountered issues. Check DFSR event logs." -ForegroundColor Yellow
}
# Wait for cleanup to complete
Start-Sleep -Seconds 60
# Verify space reclaimed
$conflictPath = $membership.ConflictAndDeletedPath
$currentSize = (Get-ChildItem $conflictPath -Force -Recurse -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum / 1MB
Write-Host "Current ConflictAndDeleted size: $([math]::Round($currentSize, 2)) MB" -ForegroundColor Green
# Remove ConflictAndDeletedManifest.xml for additional cleanup
$manifestPath = Join-Path $conflictPath "ConflictAndDeletedManifest.xml"
if (Test-Path $manifestPath) {
Remove-Item $manifestPath -Force
Write-Host "Removed ConflictAndDeletedManifest.xml" -ForegroundColor Green
}
Manual Cleanup Procedures
Safe Manual File Deletion
# CAUTION: Only delete old files from ConflictAndDeleted
# Do not delete files less than 30 days old (may still be needed for replication)
# List files older than 30 days
$conflictPath = "C:\Windows\SYSVOL\domain\DfsrPrivate\ConflictAndDeleted"
$oldFiles = Get-ChildItem $conflictPath -Force -Recurse |
Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)}
Write-Host "Files older than 30 days: $($oldFiles.Count)" -ForegroundColor Cyan
$totalSize = ($oldFiles | Measure-Object -Property Length -Sum).Sum / 1GB
Write-Host "Total size: $([math]::Round($totalSize, 2)) GB" -ForegroundColor Yellow
# Preview files to be deleted
$oldFiles | Select-Object FullName, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}}, LastWriteTime |
Sort-Object LastWriteTime |
Out-GridView -Title "Files to be deleted (older than 30 days)"
# Delete old files (with confirmation)
$oldFiles | Remove-Item -Force -Confirm
# Alternative: Delete without confirmation (USE WITH CAUTION)
# $oldFiles | Remove-Item -Force
# Verify space reclaimed
$newSize = (Get-ChildItem $conflictPath -Force -Recurse -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum / 1GB
Write-Host "ConflictAndDeleted size after cleanup: $([math]::Round($newSize, 2)) GB" -ForegroundColor Green
Pre-Emptive Staging Cleanup
# Clean staging folder to prevent disk space issues
$stagingPath = "C:\Windows\SYSVOL\domain\DfsrPrivate\Staging"
# Check staging folder size
$stagingSize = (Get-ChildItem $stagingPath -Force -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum / 1MB
Write-Host "Staging folder size: $([math]::Round($stagingSize, 2)) MB" -ForegroundColor Cyan
# DFSR automatically cleans staging files
# Manual cleanup only if staging quota is exceeded
# Force staging cleanup via WMI
$membership = Get-DfsrMembership | Select-Object -First 1
$guid = $membership.Identifier
wmic /namespace:\\root\microsoftdfs path dfsrreplicatedfolderinfo where "replicatedfolderguid='$guid'" call cleanupstagingdirectory
Monitoring and Alerting
DFSR Health Monitoring
# Monitor ConflictAndDeleted usage
function Get-DfsrConflictUsage {
$memberships = Get-DfsrMembership
$results = @()
foreach ($membership in $memberships) {
$conflictPath = $membership.ConflictAndDeletedPath
$quota = $membership.ConflictAndDeletedQuotaInMB
if (Test-Path $conflictPath) {
$currentSize = (Get-ChildItem $conflictPath -Force -Recurse -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum / 1MB
$percentUsed = ($currentSize / $quota) * 100
$results += [PSCustomObject]@{
GroupName = $membership.GroupName
FolderName = $membership.FolderName
QuotaMB = $quota
UsedMB = [math]::Round($currentSize, 2)
PercentUsed = [math]::Round($percentUsed, 2)
Status = if ($percentUsed -gt 90) { "CRITICAL" }
elseif ($percentUsed -gt 75) { "WARNING" }
else { "OK" }
}
}
}
return $results | Format-Table -AutoSize
}
# Run monitoring
Get-DfsrConflictUsage
# Check DFSR backlog
Get-DfsrBacklog -GroupName "Domain System Volume" -FolderName "SYSVOL Share" -SourceComputerName DC01 -DestinationComputerName DC02
# Monitor replication health
Get-DfsrState | Format-Table -AutoSize
# Check for replication errors
Get-WinEvent -FilterHashtable @{LogName='DFS Replication';Level=2,3;StartTime=(Get-Date).AddHours(-24)} |
Select-Object TimeCreated, Id, LevelDisplayName, Message |
Format-Table -Wrap
Automated Monitoring Script
# Monitor-DfsrStorage.ps1
param(
[int]$WarningThreshold = 75,
[int]$CriticalThreshold = 90,
[string]$EmailTo = "admin@company.com",
[string]$SmtpServer = "smtp.company.com"
)
$alerts = @()
$memberships = Get-DfsrMembership
foreach ($membership in $memberships) {
$conflictPath = $membership.ConflictAndDeletedPath
$quota = $membership.ConflictAndDeletedQuotaInMB
if (Test-Path $conflictPath) {
$currentSize = (Get-ChildItem $conflictPath -Force -Recurse -ErrorAction SilentlyContinue |
Measure-Object -Property Length -Sum).Sum / 1MB
$percentUsed = ($currentSize / $quota) * 100
if ($percentUsed -gt $CriticalThreshold) {
$alerts += [PSCustomObject]@{
Severity = "CRITICAL"
Group = $membership.GroupName
Folder = $membership.FolderName
UsedMB = [math]::Round($currentSize, 2)
QuotaMB = $quota
PercentUsed = [math]::Round($percentUsed, 2)
Message = "ConflictAndDeleted usage exceeds $CriticalThreshold%"
}
}
elseif ($percentUsed -gt $WarningThreshold) {
$alerts += [PSCustomObject]@{
Severity = "WARNING"
Group = $membership.GroupName
Folder = $membership.FolderName
UsedMB = [math]::Round($currentSize, 2)
QuotaMB = $quota
PercentUsed = [math]::Round($percentUsed, 2)
Message = "ConflictAndDeleted usage exceeds $WarningThreshold%"
}
}
}
}
if ($alerts.Count -gt 0) {
$body = $alerts | ConvertTo-Html -Head "<style>table{border-collapse:collapse;}th,td{border:1px solid black;padding:5px;}</style>" | Out-String
Send-MailMessage -To $EmailTo `
-From "dfsr-monitor@company.com" `
-Subject "DFSR Storage Alert - $($alerts.Count) Issues Detected" `
-Body $body `
-BodyAsHtml `
-SmtpServer $SmtpServer
Write-Host "Alert email sent to $EmailTo" -ForegroundColor Yellow
}
else {
Write-Host "All DFSR storage usage within acceptable limits" -ForegroundColor Green
}
Best Practices
DFSR Storage Optimization
# 1. Right-size ConflictAndDeleted quota
# Set based on replication volume and change frequency
# Low-change environments: 100-200 MB
# High-change environments: 500-1000 MB
# 2. Schedule regular cleanup
# Create scheduled task for automated cleanup
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:\Scripts\Clean-DfsrConflictAndDeleted.ps1"
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Sunday -At 2am
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
Register-ScheduledTask -TaskName "DFSR ConflictAndDeleted Cleanup" `
-Action $action `
-Trigger $trigger `
-Principal $principal `
-Description "Weekly cleanup of DFSR ConflictAndDeleted folders"
# 3. Monitor disk space proactively
# Set up disk space alerts below 20% free
# 4. Optimize file filters
# Exclude unnecessary files from replication
Set-DfsrMembership -GroupName "Data Replication Group" `
-FolderName "Public" `
-FileFilter "*.tmp,*.temp,~*,*.bak"
# 5. Use read-only replicated folders where appropriate
Set-DfsrMembership -GroupName "Data Replication Group" `
-FolderName "Software" `
-ReadOnly $true
# 6. Implement storage tiers
# Move infrequently accessed data to cheaper storage
# Use Storage Spaces or tiered volumes
Disaster Recovery Preparation
# Backup DFSR configuration
$backupPath = "C:\Backup\DFSR-Config-$(Get-Date -Format 'yyyyMMdd').xml"
# Export replication groups
Get-DfsReplicationGroup | Export-Clixml -Path $backupPath
# Export replicated folders
Get-DfsReplicatedFolder | Export-Clixml -Path "C:\Backup\DFSR-Folders-$(Get-Date -Format 'yyyyMMdd').xml"
# Export membership configuration
Get-DfsrMembership | Export-Clixml -Path "C:\Backup\DFSR-Membership-$(Get-Date -Format 'yyyyMMdd').xml"
# Document current state
$report = @{
Date = Get-Date
ReplicationGroups = Get-DfsReplicationGroup | Select-Object GroupName, DomainName
ConflictUsage = Get-DfsrConflictUsage
BacklogStatus = Get-DfsrBacklog -GroupName "Domain System Volume" -FolderName "SYSVOL Share" -SourceComputerName DC01 -DestinationComputerName DC02
}
$report | ConvertTo-Json -Depth 10 | Out-File "C:\Backup\DFSR-Status-$(Get-Date -Format 'yyyyMMdd').json"
Conclusion
DFS Replication storage optimization ensures efficient disk space utilization on enterprise file servers. The procedures detailed in this guide enable:
- Quota Management: Right-sizing ConflictAndDeleted storage allocation
- WMI-Based Cleanup: Immediate disk space recovery via automation
- Proactive Monitoring: Early detection of storage consumption issues
- Scheduled Maintenance: Automated cleanup preventing disk full conditions
- Performance Optimization: Proper staging folder sizing for efficient replication
Regular monitoring of ConflictAndDeleted and staging folder usage prevents storage exhaustion and ensures reliable DFSR operation. Implement automated cleanup schedules, configure appropriate quotas based on workload characteristics, and maintain comprehensive backups of DFSR configuration for disaster recovery scenarios.