Disabling and enabling DFS namespace referrals from the command-line

At least once a month a customer asks for a command-line method to enable and disable referrals for a folder target (aka link target). Neither dfscmd.exe nor dfsutil.exe provides a way to do this. In response to the many requests we get for this functionality, we’ve posted some sample code that can be compiled into an executable tool for enabling and disabling referrals. Many thanks to Dan Lovinger, one of our DFS developers, for providing this!

Here are the parameters for using the tool:

modlink <DfsEntryPath> <ServerName> <SharePathName> [<on|off>]

 And here’s an example of disabling a referral:

modlink \contoso.comdfsrootdirsharename  server1.contoso.com sharename off

 The above command disables the folder target (aka link target) \server1.contoso.comsharename of the namespace folder \contoso.comdfsrootdirsharename.