How to create a new DFS folder without any targets using PowerShell

user2917291 picture user2917291 · Oct 24, 2013 · Viewed 7.2k times · Source

I'm trying to create a folder hierarchy for my projects using Powershell. The main project folder will not be connected to a target. The subfolders will be connected to targets on four different servers.

\\domain\production (namespace)
-projects

--000p_company_dfs_test01 (no target)
---comp (with target)
---images (with target)
---admin (with target)

--001p_company_dfs_test02 (no target)
---comp (with target)
---images (with target)
---admin (with target)

I'm having no trouble defining the hierarchies using the DFS Management window, but I can't get my head around what command I need to use to create the targetless project folders.

I have tried using New-DfsnFolder, but this command need a target-argument:

New-DfsnFolder -Path ("\\domain\production\projects\" +$project +"\")

I have also tried to add the folder using the following command:

New-Item -ItemType "directory" -Path ("\\domain\production\projects\" +$project +"\")

The command return: "Access to the path '001p_company_dfs_test02' is denied"

Powershell version:

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      -1     -1 

Any suggestions?

Best, Lars Erik

Answer

user2917291 picture user2917291 · Oct 25, 2013

The solution was surprisingly simple. Create the subfolders with targets and the parent folder will be generated automatically. There is two ways to do this:

DFSUtil Link Add "DFSUtil Link Add "\\domain\production\projects\001p_company_dfs_test02\images" "\\server1\projects\001p_company_dfs_test02\images"

Or:

Ne‌​w-DfsnFolderTarget -Path \\domain\production\projects\001p_company_dfs_test02\images -TargetPath \\domain\production\projects\001p_company_dfs_test02\images