当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 PowerShell 停用 SharePoint 中所有网站上的功能

作者:精品下载站 日期:2024-12-14 14:11:07 浏览:14 分类:玩电脑

使用 PowerShell 停用 SharePoint 中所有网站上的功能


要求:在所有 SharePoint 网站上禁用某项功能。

在 SharePoint 中部署具有编辑许可证的 Office Web 应用程序后,我们希望在 SharePoint 中的所有网站集中禁用在客户端中打开的功能。通过进入以下内容,可以从 SharePoint Web UI 直接停用功能:

  • 网站设置>>网站集功能
  • 找到目标功能并单击其旁边的“停用”按钮。

    [玩转系统] 使用 PowerShell 停用 SharePoint 中所有网站上的功能

但是,对大量网站集重复此活动很麻烦,不是吗?因此,请使用这些 PowerShell 脚本来停用 SharePoint 中所有网站的功能!

PowerShell 禁用 SharePoint 中所有网站集的功能

在这篇博文中,我们将向您展示如何禁用 SharePoint 中所有网站上的功能。如果您想暂时禁用所有站点上的某项功能,或者需要禁用某项功能以进行故障排除,这可能会很有用。我们将使用在 SharePoint 中禁用“默认情况下在客户端应用程序中打开文档”功能的示例,但您可以使用本指南来禁用任何功能。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Feature to Deactivate
$FeatureID="8a4b8de2-6fd8-41e9-923c-c7c3c00f8295"

#Get all Site collections
$SitesColl= Get-SPWebApplication | Get-SPSite -Limit ALL
#Get the Feature
$Feature = Get-SPFeature | Where {$_.ID -eq $FeatureID}

#Check if Feature exists
if($Feature -ne $null)
{
    #Iterate through through each site collection and deactivate the feature
    Foreach($Site in $SitesColl)
    {
       #Check if the Feature is activated
       if (Get-SPFeature -Site $Site.Url | Where {$_.ID -eq $FeatureId})
       {
            #DeActivate the Feature
            Disable-SPFeature -identity $FeatureID -URL $Site.URL -Confirm:$false
            Write-Host "Feature has been Deactivated on "$Site.URL -f Green
       }
       else
       {
            Write-host "Feature was not activated on "$Site.URL -f Cyan
       }
    }
}
else    
{
    Write-Host "Feature doesn't exist:"$FeatureID -f Red
}

此脚本从整个 SharePoint 环境的所有网站集中停用给定的功能 ID。

使用 PowerShell 停用 SharePoint 中所有网站上的功能:

如何停用 SharePoint 中所有网站(网站)上的某个功能?使用此 PowerShell 脚本禁用所有站点的功能:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Feature to Deactivate
$FeatureID="7201d6a4-a5d3-49a1-8c19-19c4bac6e668"

#Get all webs
$WebsColl= Get-SPWebApplication | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL

#Get the Feature
$Feature = Get-SPFeature | Where {$_.ID -eq $FeatureID}

#Check if Feature exists
if($Feature -ne $null)
{
    #Iterate through through each site collection and deactivate the feature
    Foreach($web in $WebsColl)
    {
       #Check if the Feature is activated
       if (Get-SPFeature -web $web.Url | Where {$_.ID -eq $FeatureId})
       {
            #DeActivate the Feature
            Disable-SPFeature -identity $FeatureID -URL $web.URL -Confirm:$false
            Write-Host "Feature has been Deactivated on "$web.URL -f Green
        }
        else
        {
            Write-host "Feature was not activated on "$web.URL -f Cyan
        }
    }
}
else    
{
    Write-Host "Feature doesn't exist:"$FeatureID -f Red
} 

此 PowerShell 脚本禁用 SharePoint 中所有子网站的给定功能 ID。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯