SharePoint Reverse DSC

If your SharePoint farm has internet connectivity, you can now install the SharePointDSC and all its prerequisites by simply running the following PowerShell line of code Install-Script SharePointDSC.Reverse

In my previous blog article I introduced the concept of Reverse DSC, which is nothing more than a dynamic way of extracting a Desired State Configuration (DSC) Script that represents the Current State of any given environment. In this blog article, I will guide you through the process of executing the Reverse DSC script against an existing SharePoint 2013 or 2016. Please note that while PowerShell v4 is supported by the SharePoint Reverse DSC, it is highly recommended that you upgrade your environment to PowerShell v5 to be able to fully leverage the goodness of the DSC engine.

While it is still not officially decided how the SharePoint Reverse DSC script will be distributed, I have taken the decision to go ahead and offer a temporary distribution via my Blog. A copy of the current script can be obtained here:

This version of the script currently supports the latest available bits of the SharePointDSC Module ( The package is made of two files:

  • ReverseDSC.Util.psm1, the core ReverseDSC module which is generic to all DSC Modules (not just SharePoint)
  • SharePointDSC.Reverse.ps1, the main SharePoint specific PowerShell script responsible for extracting the current state of a SharePoint Environment.

As mentioned above, this script is optimized to run under an environment that has PowerShell v5. To determine what version of PowerShell you are using, simply run the following PowerShell command:


If you are running version 4, no worries, you can either upgrade to version 5 by downloading and installing the Windows Management Framework (WMF) 5.0 on your various servers (which will cause downtime). In case your organization is not yet ready to upgrade to WMF 5, you can either download and install the PackageManagement module for PowerShell 4, or simply manually install the SharePointDSC module onto each of your servers. PackageManagement will simply be used to automatically download and install the proper version of the SharePointDSC module from the PowerShell gallery, assuming your server has internet connectivity (which it most likely won’t anyway).

How to Use

  1. Extract the content of the package onto one of the SharePoint server (Web Front-End or Application server). Make sure that both the .psm1 and .ps1 files are in the same folder.
  2. In an elevated PowerShell session (running as administrator), execute the SharePointDSC.Reverse.ps1 script.
  3. If you do not have the required version of the SharePointDSC module installed, you will be prompted to automatically download it or not. Note that this requires your server to have internet connectivity. (Note that I recommend you manually get the module v1.5.0.0. onto you server)
  4. When prompted to provide Farm admin credentials, simply enter credentials for any account that has Farm Admin privileges on your farm.
  5. The script may prompt you several times to enter credentials for various Managed Accounts in your environment. This is required in order for DSC to be able to retrieve any Password Change Schedules associated with your managed accounts. Simply provide the requested credentials for each prompt.
  6. The script will scan through all components supported by the SharePointDSC module and then compile the resulting DSC Configuration Script. Once finished, it will prompt you to specify the path to an existing folder where the resulting .ps1 DSC Configuration Script will be saved.
  7. The DSC Configuration Script will be saved with the name “SP-Farm.DSC.ps1” under the specified folder path. You can open the .ps1 file to take a close look at its content. the top comments section will provide insights about the Operating System versions, the SQL Server Versions, and all the patches installed in your farm.
  8. To validate that the Reverse DSC process was successful, simply execute the resulting SP-Farm.DSC.ps1 file. It will prompt you to pick a passphrase and will automatically compile a .meta.mof and a .mof file for each of the server in your farm.

Now that you have your resulting .MOF files, you can use them to replicate your environment to another location on-premises, upload the resulting .ps1 into Azure Automation to create a replica of your environment in the cloud, or on-board your existing environment onto DSC. The next Blog post in this series will go through the steps you need to take to on-board an existing SharePoint environment onto DSC using the ReverseDSC process.

10 thoughts on “SharePoint Reverse DSC

  1. Hi Nik,
    This is a great script and I have been using it regularly as a way to keep my custom wsp solution the same versions across several sharepoint farms.

    I especially like that the script will copy the custom solution to the temp directory along with the configuration settings. However, I have noticed that in some instances it does not copy the custom solutions to the temp directory and in others it does.

    Do you have an idea why this might be happening?

      1. Nik,
        Thanks for getting back to me so quickly. I think I found the issue

        The script is being run on several different farms. It works in my lab, and seems to work on most of my farms. I think the issue is that I was not running the script under the SharePoint Farm install account. I noticed that on the farms that did NOT work, I had used a account that was not used for installation of SharePoint.

        Does that make sense ?

        Thanks again


        1. It does. The account needs access to the configuration db to extract the solutions. I always recommend running the script as the farm account instead.

          1. Nik,

            Just a follow up with my last issue. It was the account that was the issue. Once I had the right setup account , everything worked as normal.

            Thanks for the quick response.

            By the way, this script is making me look like a genius. My boss loves that I can not only replicate SharePoint farms , bu also pull out the custom webparts from the farm.

  2. Nik,

    I am running into an issue with the central administration: an invalid value for centraladministrationport is specified

    Can you explain what is needed?

      1. I figured out the issue for this part. It’s cause we do not have a HTTP binding on central administration and your code only accounts for that.

        After changing IisSettings[0].ServerBingings to [0].SecureBindings it worked but is now failing on the URI which I assume is cause it’s showing * as it and not a URL.

        I assume this is due to a poor setup our side.

Leave a Reply

Your email address will not be published. Required fields are marked *