It takes many clicks on DFS Management console to open each DFS namespace and root and walk trough them. Alternatively, you can use the DFSN module on Windows Server 2012 but the command Get-DFSNFolderTarget doesn't understand the multi level structure, it can only wok in one given DFSN root.
Let's take an example, we want to know which file server and which folder the following path points to : \\tatooine.com\root\cities\moseisley\cantina\stock
In the DFS management console, you have to
- add \\tatooine.com\root namespace for display
- drill down to the MosEisley folder to find that it actually points to \\c3podc1\moseisley
- so then you add \\c3podc1\moseisley DFS root to the console
- drill down to the Stock folder under Cantina and find that it points to \\fileserver\share1\documents folder
Find a target in a multi-level DFS structure on DFS Management Console |
It's not very rewarding after you get the 5th of these requests from users...
Here is a quick script which can walk through the folder structure, just specify the full path of a folder and it will tell you for each level where it points to, the script requires the DFSN PS module installed on the box - included in the DFS Management Tools Feature.
If the given folder level is just a DFS folder without target, obviously it will show and empty target, e.g.:
On the above picture:
- \\tatooine.com\root\cities is just a folder because it doesn't point anywhere
- \\tatooine.com\root\cities\moseisley points to another DFS root
- \\c3podc1\moseisley\Cantina is again just a folder without DFS target
- \\c3podc1\moseisley\Cantina\stock is the pointer we wanted to look for and it points to \\fileserver\share1\documents
Here is the code:
param([string]$folderpath = "")
$erroractionpreference = "silentlycontinue"
Import-module DFSN
$arr = $folderpath.split("\\")
$basepath = ("\\" + $arr[2] + "\" + $arr[3])
$testpath = $basepath
# go from the 4th element of the path and try to get the target of each
for($i = 4; $i -lt $arr.count; $i++){
$testpath = $testpath + "\" + $arr[$i]
$result = get-dfsnfoldertarget $testpath
$testpath + "->" + $result.targetpath
if($result.targetpath){
$testpath = $result.targetpath
}
}