سؤال

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?

هل كانت مفيدة؟

المحلول

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
        }
    }
  }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top