DFS and PowerShell: New DFSN Root and Folders
Distributed File System (DFS) is a set of client and server services that allow an organization using Microsoft Windows servers to organize many distributed SMB file shares into a single namespace or DFS root. Here we will use the DFSN PowerShell commands to create a new DFS root and add two new DFS folders within this namespace.
The code:
#dfsroot
install-windowsfeature FS-DFS-Namespace, FS-DFS-Replication -IncludeManagementTools -restart
mkdir c:\DFSRoot\NameSpace1
New-SmbShare –Name NameSpace1$ –Path C:\DFSRoot\NameSpace1 -ReadAccess "Authenticated Users"
New-DfsnRoot -TargetPath "\\TUS-DC3\NameSpace1$" -Type DomainV2 -Path "\\AACO.local\NameSpace1"
new dfs folder \\servername\client$
mkdir E:\NameSpace1\Client1
New-SmbShare –Name Client1$ –Path E:\NameSpace1\Client1 -ReadAccess "Authenticated Users"
New-DfsnFolder -Path "\\AACO.local\NameSpace1\Client1" -TargetPath "\\TUS-DC3\Client1$" -EnableTargetFailback $True
#new folder target \\servername\server$
mkdir E:\NameSpace1\Server1
New-SmbShare –Name Server1$ –Path E:\NameSpace1\Server1 -ReadAccess "Authenticated Users"
New-DfsnFolder -Path "\\AACO.local\NameSpace1\Server1" -TargetPath "\\TUS-DC3\Server1$" -EnableTargetFailback $True
Where:
Domain Name = AACO.local
Server Name = TUS-DC3
Namespace Share = NameSpace1$
Name = NameSpace1
Share 1 = Client1$
Share 1 Name = Client1
Share 2 = Server1$
Share 2 Name = Server1