문제

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