Traditionally, The DFS objects are backed up along with the rest of your Active Directory, during a System State backup. To restore one, you have to restore AD and do an authoritative restore of the DFS object in question. I know, there are various ways to recover objects, but again that's not the point.
The point is, there's an easy way to backup your DFS namespaces, using dfsUtil.
DfsUtil is a command line utility that comes with Windows server. To use it to backup a namespace, you simply type:
dfsUtil root export \\domain\rootname rootname.xml
The configuration of the namespace and all its links will be stored to an XML file. Then to restore it, you create a new root, then import the xml file again like so:
dfsUtil root addDom \\servername\rootname
dfsUtil root import set \\domain\rootname rootname.xml
Where servername is the name of one of the servers to host the namespace (and must have a share with the same name as the root to be created).
Anyway, I said PowerShell didn't I? Well, I haven't found a good way (yet) to do the whole thing in PowerShell (all my DFS code is currently in C++), but what we can do is use PowerShell to gather all of the DFS roots in our Active Directory and use dfsUtil to back them up.
The following script enumerates the domains in the forest, and for each domain, enumerates the domain DFS roots. For each one, it calls dfsUtil to backup the namespaces. The script creates a subfolder for each domain and places the backup files in the correct folder.
Before you complain about my coding style, please be aware that I intentionally leave scripts pretty bare bones, and I avoid hard-to-read piplines, because I want the reader to be able to understand the script. So I'm sure there are plenty of improvements you could make to pretty up the output, catch errors, etc. Feel free.
- Backup DFS Namespaces Using PowerShell
- Translate Active Directory Name Formats Using PowerShell
- List Linux Users in Active Directory Using PowerShell
- Enable Trust for Delegation in Active Directory Using PowerShell
- TCP/IP Subnet Math with PowerShell - What AD Site is that Server in?
- List Sites and Subnets in Active Directory with PowerShell
- Find Disabled Users in Active Directory with PowerShell
- List Forest-wide Group Memberships with PowerShell
- Find Old Computer Accounts in AD with PowerShell
- List SPNs in Active Directory with PowerShell
- List Domain Controllers in Active Directory