1

What is the correct way of disabling a feature using PowerShell? I'm gonna add a script to task scheduler that's deactivates the Minimal Download Strategy feature from all the new sites that are created each day.

However, i can't come to a conclusion of which way is the correct way to do it.

$web = "http://server/sites/something"
$web.EnableMinimalDownload = $false
$web.Update()

Or

Disable-SPFeature -identity "Minimal Download Strategy" -URL "http://server/sites/something"

Are there any differences or are one way better then the other?

1 Answer 1

3

The first way is kind of manual way where you are creating the SPWeb object and then disabling the property of the object.

The second way is the correct method. It uses the Out of the box PowerShell CMDLet to disable the feature.

If you are planning to disable for all then use

foreach($webApp in Get-SPWebApplication)
{
    foreach ($SPsite in $webApp.Sites)
    {
       foreach($SPweb in $SPsite.AllWebs)
        {
             Disable-SPFeature –identity "MDSFeature" -URL $spweb.URL -confirm:$false
        }
    }
  }
1
  • Excellent answer, thank you! One thing i noticed when i was setting the property of SPweb to false, is that if you check site features in the UI, Minimal Download Strategy is still presented as "Active". Commented Jan 21, 2015 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.