Disable Minimal Download Strategy Across All Sites and Site Collections via PowerShell

Minimal Download Strategy… the bane of pretty much everyone’s existence… well, at least in SharePoint. Especially if you’re using JavaScript (who would do that?!).  It’s useless. And while it was created for a good purpose, I have yet to come across a client that actually needed it over the pains it generally causes.

I recently had a client ask me to remove it from everything (hear that large cheering section in the stadium?)… so I threw together a script that will disable it from every site in a web application. Here she is!

# Load the SharePoint PowerShell Module… if not running this in the SharePoint Console…
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue
 
# URL to our web application
$WebApp = "https://sharepoint.sharepont.sharepoint.com"
 
# Get all webs within a web application
$Webs = Get-SPWebApplication $WebApp | Get-SPSite -Limit All | Get-SPWeb -Limit All

# Loop through said webs
foreach ($Web in $Webs)
{
    # Is MDS enabled?
    $MDSEnabled = Get-SPFeature -web $Web.URL  | Where-object {$_.DisplayName -eq "MDSFeature"}
  
    # If it is… disable it!
    if ($MDSEnabled -ne $null)
    {
        Disable-SPFeature –identity "MDSFeature" -URL $Web.URL -confirm:$false
    }
}

Advertisement
%d bloggers like this: