DFS-N consistency analysis and export of the structure

When managing the DFS you have to pay attention to consistency. The flexibility in the configuration also harbors dangers.

You should make sure that targets are only integrated via a link and that there are no redundant connections. This leads to problems sooner or later.

The following command outputs a status of the current configuration.

DFSDiag / TestDFSIntegrity / DFSRoot:\ad\public / Recurse / Full

The following Powershell script exports all DFS connections as CSV files.

[CmdletBinding()] 
param(
    $DFSPath = '\\ad\public\*'
)

Write-Progress "Getting all DFS folders for $DFSPath (this can take a very long time)" -PercentComplete -1
$DFSTree = Get-DfsnFolder $DFSPath

$i = 1
$DFSTree | ForEach-Object{
    Write-Progress "Getting DFS Folder Targets for $($_.Path)" -PercentComplete (($i / $DFSTree.Count) *100)
    
    $DFSTarget = Get-DfsnFolderTarget $_.Path | Select Path,TargetPath,State

    $Result = [ordered]@{
        Path = $DFSTarget.Path
        TargetPath = $DFSTarget.TargetPath
        State = $DFSTarget.State
        "ValidFrom_$Env:ComputerName" = Test-Path $DFSTarget.Path
    }
    
    New-Object PSObject -Property $Result
    $i++

} | Sort Path | Export-Csv "c:\temp\DFS-$(Get-Date -format yyyy-MM-dd).csv" -NoTypeInformation

Permanent link to this post: https://help.migraven.com/dfs-n-konsistenz-analyse-und-export-der-struktur/

Leave a Comment

Your email address will not be published.