Search code examples
powershellchef-infrawindows-server-2012-r2microsoft-distributed-file-system

Publishing DFS replication to a Namespace


I'm creating a chef cookbook which runs on 2 Windows boxes

  • Turns on DFS Windows feature
  • Creates a folder and sets it up for replication
  • Creates a Replication Group and registers it to the ActiveDirector

The recipes are calling PowerShell commands to automate these tasks. This is working well.

What I still need to to is creating a Namespace and Publishing the replication in that Namespace.

Based on this tutorial, I managed to do it in no time with the DFS Management UI.

I need a way to do it with PowerShell or with anything what I can call from Chef.

Note: If I can publish the replication to an already existing Namespace, that's already a half solution for me.

Update: I'm using Windows 2012 R2. ( The latest version provided on AWS.)


Solution

  • On Server 2012 R2 you can use the DFS cmdlets for DFS administration.

    $path   = '\\server\share'
    $domain = 'example.org'
    $ns     = 'mynamespace'
    $group  = 'RGroup'
    $name   = 'myreplicatedfolder'
    
    New-DfsnRoot -TargetPath $path -Type DomainV2 -Path "\\$domain\$ns"
    New-DfsReplicatedFolder -GroupName $group -FolderName $name `
      -DfsnPath "\\$domain\$ns\$name"
    

    I don't have access to a DFS environment right now, but somthing like the above should work.