Site Loader

Hello everybody,

I was looking for a solution to create a DFS namespace (DFSN) folder structure. This because I wanted to create a shares folder and in that folder my shares and its target paths. So I was looking on the internet how to do that, but I couldn’t find the right answer.

And of course we are doing it in PowerShell! Because in large setups you do not want to do this by hand ;-).

PROBLEM:
I used the command new-dfsfolder and that command requires parameters –path and –targetpath. The PowerShell code I used was.

I used the command new-dfsfolder and that command requires parameters –path and –targetpath.
The PowerShell code I used:

$target = '\\servername.domain.local\cust\testsander34.nl\Shares\'
$path = '\\domain.local\cust\testsander34.nl\Shares\'
New-DfsnFolder -Path $path -TargetPath $target

The result looks like this
dfsnwrong

So I tried to create a shared folder in my shares DFSN folder, but that did not work….

$target = '\\servername.domain.local\cust \testsander34.nl\Shares\testshare'
$path = '\\domain.local\Cust\testsander34.nl\Shares\testshare'
New-DfsnFolder -Path $path -TargetPath $target

The error I see was:
dfsnerror

The reason is because the shares folder contains a target. And that was just my problem because then you cannot create subfolders in DFS….

SOLUTION:
After some digging into the folders of my DFSN I saw something interesting.

Use:

Get-DfsnFolder -Path '\\domain.local\Cust\testsander35.nl\*' | fl *

The result will look like this

Path                 : \\domain\Cust\testsander35.nl\.DFSFolderLink 
TimeToLiveSec         : 300 
State                 : Online 
Flags                 : 
Description           : 
NamespacePath         : \\domain\Cust\testsander35.nl\.DFSFolderLink 
TimeToLive           : 300 
PSComputerName       : 
CimClass             : ROOT/Microsoft/Windows/dfsn:MSFT_DfsNamespaceFolder
CimInstanceProperties : {Description, Flags, NamespacePath, State...} 
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

The path and NamespacePath are important for our solution.

So I used the similar paths to create my shares folder in DFSN including .DFSFolderLink.

$targetpath = '\\domain.local\cust\testsander35.nl\Shares\.DFSFolderLink' 
$path = '\\domain.local\cust\testsander35.nl\Shares\.DFSFolderLink' 
New-DfsnFolder -Path $path -TargetPath $TargetPath

After these lines of code, I was able to create share under the shares folder.

$target = '\\servername. domain.local\cust\testsander35.nl\Shares\testshare' 
$path = '\\domain.local\Cust\testsander35.nl\Shares\testshare' 
New-DfsnFolder -Path $path -TargetPath $target

Result:

dfsnoke

Have Fun creating you’re DFS namespace!

Sander