Create or delete a DFS link using WFA



is it possible to create or delete a DFS link using WFA?



A customer uses an selfwritten script to create, rename and delete qtrees on a NetApp storagesystem. Furthermore this script creates DFS links via command "dfscmd /map "\\<DFS_NAME_SPACE\vol\qtree" "\\<netapp_controller>\vol\qtree"".


The qtree management can be easily integrated into WFA. But can we trigger Powershell cmdlets of DFS?




Re: Create or delete a DFS link using WFA

While I have not done this personally, I believe the answer is yes.  You will need to create a custom command with the dfs powershell code.  I think credentials will be the hardest part of this.  The service account running wfa will need to have permission to create the dfs link, or you will need to store credentials in the wfa credential cache, and run the custom command with these credentials.  I would like to see the code when you are done.  This is something that I believe will benefit others.

Re: Create or delete a DFS link using WFA

Yes, this can be done via custom command. I have searched the internet and there are PS cmdlets to create/modify/delete DFS links (Win2012). These can be integrated easisly in WFA, I think.

As you mentioned, the credentials could be a problem. Since in WFA, we cannot add Windows credentals. Credentials with type of ONTAP, OnCommand and vCenter can be added.

Perhaps the cmdlets can be run remotely or the DFS role and feature must be installed on WFA server (WFA and DFS aren't running on same system).


If nobody has done this before, I have to test this. I will share my results and source code.





Re: Create or delete a DFS link using WFA



   Have you looked at the "Other" credentials type.  This may allow us to utilize the wfa cache to store credentials for the windows service account, and the windows server that has the dfs role.



Re: Create or delete a DFS link using WFA



   Look at the "Get-WfaCredentials" commandlt.  I think this may help you.



Re: Create or delete a DFS link using WFA

Hey there,


I think you should be able to use the DFS PowerShell CmdLets in Server 2008R2\2012R2 from within WFA to create DFS links but you would need to:


  • Install the DFS management tools\PowerShell module on your WFA server
  • Add the DFSN PowerShell module to your WFA Servers PowerShell profile
  • Restart the WFA Service.


For example:


  • Install the DFS managment tools (list available CmdLets for DFS administration)

PS C:\> Install-WindowsFeature RSAT-DFS-Mgmt-Con

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Remote Server Administration Tools, DFS M...

PS C:\> import-module dfsn
PS C:\> Get-Command -Module dfsn

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Function        Get-DfsnAccess                                     dfsn
Function        Get-DfsnFolder                                     dfsn
Function        Get-DfsnFolderTarget                               dfsn
Function        Get-DfsnRoot                                       dfsn
Function        Get-DfsnRootTarget                                 dfsn
Function        Get-DfsnServerConfiguration                        dfsn
Function        Grant-DfsnAccess                                   dfsn
Function        Move-DfsnFolder                                    dfsn
Function        New-DfsnFolder                                     dfsn
Function        New-DfsnFolderTarget                               dfsn
Function        New-DfsnRoot                                       dfsn
Function        New-DfsnRootTarget                                 dfsn
Function        Remove-DfsnAccess                                  dfsn
Function        Remove-DfsnFolder                                  dfsn
Function        Remove-DfsnFolderTarget                            dfsn
Function        Remove-DfsnRoot                                    dfsn
Function        Remove-DfsnRootTarget                              dfsn
Function        Revoke-DfsnAccess                                  dfsn
Function        Set-DfsnFolder                                     dfsn
Function        Set-DfsnFolderTarget                               dfsn
Function        Set-DfsnRoot                                       dfsn
Function        Set-DfsnRootTarget                                 dfsn
Function        Set-DfsnServerConfiguration                        dfsn


  • Add the DFS PowerShell module to your WFA profile

C:\>robocopy /E "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DFSN" "C:\Program Files\NetApp\WFA\PoSH\Modules\DFSN"

C:\>notepad "C:\Program Files\NetApp\WFA\PoSH\profile.ps1"

$ModulesDir = split-path $MyInvocation.MyCommand.Path

Import-Module $ModulesDir\Modules\WFA
Import-Module $ModulesDir\Modules\WFAWrapper
Import-Module $ModulesDir\Modules\DataONTAP

#Add the DFS PowerShell Module
Import-Module $ModulesDir\Modules\DFSN

#Loading the MySql connector/net.
$MySqldir= "$ModulesDir\..\mysql"
Add-Type -Path "$MySqlDir\lib\connectors\net_2.0\6.8.3\"


NOTE: technically you don't really need to copy the powershell module from the windows system directory to the WFA modules directory. You could add it directly using:


Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DFSN


however it's probably a advisable to create a copy of the module in the WFA modules directory incase someone uninstalls the DFS mangement tools windows feature on your WFA server which would break your workflows. Having a seperate copy of the PowerShell module in the WFA modules directory would mitigate the risk of that from occurring.


  • Restart the WFA Service

PS C:\> Restart-Service -Name NA_WFA_SRV


Once your done configuring WFA you should then be able to use the DFSN PowerShell CmdLets within your WFA Commands to create\set DFS links (See "Get-Help New-DfsnFolder" and "Get-Help Set-DfsnFolder")

Hope that helps



If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: Create or delete a DFS link using WFA

Hi Mike, hi Matt,


thanks for your input. I appreciate your help!

I'll implement this in my lab to see if it's working. I'll share my results.


Thanks again and best regards,


Re: Create or delete a DFS link using WFA



With my previous employer we created a custom command in WFA using powershell. You can call the dfsutil or dfscmd command from within powershell. Generally speaking, any DOS command you run can be ran within powershell.  So you need to make sure the dfsutil command is available on the WFA server.  Below is a link to getting the dfsutil/dfscmd available on the WFA server.


With that said, from a WFA standpoint, you need to make sure the service running the WFA Server is an account that has access to create dfs links within the namespace(s) of choice. This is because WFA will run the poweshell script/command as that account.


I don't have the commands at hand now because I no longer have access to their environmnet. Also it was highly customized for their needs, so their commands wouldn't be 'plug and play'


I hope this helps you.  Feel free to DM me for more information.

Re: Create or delete a DFS link using WFA

I have created the workflows and commands for DFS integration. Please see attachement.


The following steps have to be done before it works:


- Install RSAT for DFS


PS C:\Windows\system32> Install-WindowsFeature RSAT-DFS-Mgmt-Con

Success Restart Needed Exit Code Feature Result
------- -------------- --------- --------------
True No Success {Remote Server Administration Tools, DFS M...



- Add the module to WFA PS profile in "C:\Program Files\NetApp\WFA\PoSH\profile.ps1"


# Add the PowerShell Module
Import-Module C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DFSN



- Create a domain user for WFA, which has permissions to create and delete DFS links


- Assign this user to WFA server service and restart the service



This works only on Windows Server 2012 and higher, since Microsoft has implemented the PS commandlets to those versions.


If you have questions, please come back to me.