Is your DFS structure up to date?

Distributed File System is a technology that has been around since the days of NT 4.0 so as you can imagine entropy can run wild in a DFS structure. It is paramount to remove old targers to servers gone the way of the zune player: We have all heard the phrase “My computer is slow” and depending on the end users clout in the company and your position in the company, the ticket for the slow computer may end up on your desk.

A tell tale sign of old DFS targets is an end users complaint when accessing network resources and enumerating network folders.
When I was new to a company my manager told me that the average end user had a delay of around 15 seconds (aka an eternity) when they were browsing the DFS root in explorer. Browsing the DFS folders I found some loaded faster than others, the experience was the same browsing folders in the DFS snapin. all the servers had gig links and were in the same datacenter so what could the issue be?
The answer was old DFS targets for servers that no longer existed. When determining which DFS path is presented the cost for each link is determined by the servers site, if DFS cannot find the server (because the server is no longer in DNS) DFS lookup time is greatly increased.
I have put together a simple script to run on a DC which identifies servers that exist in DFS but are not in DNS. I’ve found this handy when retiring old servers and use it regularly to ensure speedy enumeration of DFS targets.

Function Find-DeadDFSLinks {            
 $DFSPaths = Get-WmiObject -Class Win32_DFSTarget             
 $results = $DFSPaths|select Linkname, Sharename, Servername, @{Name="Reachable"; Expression= {Test-Connection $_.Servername-Count 1 -Quiet}}            
 $Results | where {$_.Reachable-eq $false}|sort Servername