How do I install the DFSR module for Powershell on Windows Server 2012?

I have a full GUI installation of Windows Server 2012r2 2012 with the DFS Management snap-in installed for Server Manager. I want to use the DFSR module for Powershell to monitor DFS replication. However, this module and its associated commands are not available in Powershell:

PS C:\Windows\system32> Import-Module DFSR
Import-Module : The specified module 'DFSR' was not loaded because no valid module file was found in any module directory.

Here are two snippets from the output of the Powershell command Get-WindowsFeature to show which DFS features are installed.

[X] File And Storage Services                           FileAndStorage-Services        Installed
[X] File and iSCSI Services                         File-Services                  Installed
    [X] File Server                                 FS-FileServer                  Installed
    [ ] BranchCache for Network Files               FS-BranchCache                 Available
    [ ] Data Deduplication                          FS-Data-Deduplication          Available
    [ ] DFS Namespaces                              FS-DFS-Namespace               Available
    [X] DFS Replication                             FS-DFS-Replication             Installed
    [ ] File Server Resource Manager                FS-Resource-Manager            Available
    [ ] File Server VSS Agent Service               FS-VSS-Agent                   Available
    [ ] iSCSI Target Server                         FS-iSCSITarget-Server          Available
    [ ] iSCSI Target Storage Provider (VDS and V... iSCSITarget-VSS-VDS            Available
    [ ] Server for NFS                              FS-NFS-Service                 Available
[X] Storage Services                                Storage-Services               Installed

...

[X] File Services Tools                         RSAT-File-Services             Installed
    [X] DFS Management Tools                    RSAT-DFS-Mgmt-Con              Installed
    [ ] File Server Resource Manager Tools      RSAT-FSRM-Mgmt                 Available
    [ ] Services for Network File System Man... RSAT-NFS-Admin                 Available
    [ ] Share and Storage Management Tool       RSAT-CoreFile-Mgmt             Available

How do I install and access the DFSR module in Powershell?

EDIT: I just discovered that the server is actually running Windows Server 2012, not 2012r2. That's why the built-in DFSR module is not available. Updating to WMF/Powershell 5.1 does not make the new DFSR module available. I have updated the title, question, and tags on this post accordingly. One workaround is to install a third-party DFSR module.


Solution 1:

It seems to be failing to load to types DLL. Can you try verifying the DLL files is in the Dfsr folder, and if so, opening PowerShell and running the following command:

Add-Type -Path C:\Windows\system32\WindowsPowerShell\v1.0\Modules\dfsr\DfsrTypes.dll

If that errors out, try right clicking on the DLL file and going to Properties and seeing if there is a 'Unblock' button - if so, try unblocking it.

If it still doesn't work, please let me know. It works for me on Windows 8/2012, so it may be a difference in configuration. I'll try a few things out to see if I can duplicate the error.

By Mike Walker from Gallery Technet