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

[玩转系统] 使用 PowerShell 查找 SharePoint 中的所有非活动功能

作者:精品下载站 日期:2024-12-14 13:44:23 浏览:10 分类:玩电脑

使用 PowerShell 查找 SharePoint 中的所有非活动功能


SharePoint 中的非活动功能是什么?嗯,已安装但未在任何地方激活的功能!

以下是用于查找 SharePoint 不活动功能的 PowerShell 脚本:


Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

$InactiveFeatures = @()

#Get All installed features on respective scopes
$WebAppFeatures =  Get-SPFeature | Where-Object {$_.Scope -eq "WebApplication" }
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Site" } 
$WebFeatures = Get-SPFeature| Where-Object {$_.Scope -eq "Web" }

Write-host "Checking Web Application Scoped Features..."
foreach ($WebAppFeature in $WebAppFeatures)
{
       $Flag = $False
       foreach ($WebApp in Get-SPWebApplication)
       {
         if ((Get-SPFeature -WebApplication $WebApp.URL | Where-Object {$_.Id -eq $WebAppFeature.id}) -ne $null)
         {
            #We found that the Feature is active, Lets end up the loop
            $Flag = $True
            break 
         }
      }
  if($Flag -eq $False)
  {
     Write-Host "$($WebFeature.DisplayName) is not Active on any Web Application!)"
  }   
}

   Write-Host "`nChecking Site Collection Scoped Features..."
   foreach ($SiteFeature in $SiteFeatures)
   {
       $Flag = $False
       :WebAppLoop1 foreach ($WebApp in Get-SPWebApplication)
      {
      foreach($site in $WebApp.Sites)
      {
          if ((Get-SPFeature -Site $Site.URL | Where-Object {$_.Id -eq $SiteFeature.id}) -ne $null)
          {
            #We found that the Feature is active, Lets end up the loop
            $Flag = $True
            break WebAppLoop1 
          }
      }
  }
   if($Flag -eq $False)
   {
      Write-Host "$($SiteFeature.DisplayName) is not Active on Any Site Collection!"
   }   
}

 Write-host "`nChecking Web Scoped Feature..."
   foreach ($WebFeature in $WebFeatures)
   {
       $Flag = $False
    #I'm limiting to a single web application, Remove ""https://sharepoint.crescent.com" to process all WebApps
       :WebAppLoop2 foreach ($WebApp in Get-SPWebApplication "https://sharepoint.crescent.com")
       {
         foreach($Site in $WebApp.Sites)
         {
           foreach($Web in $Site.AllWebs)
           {
            if ((Get-SPFeature -Web $Web.URL | Where-Object {$_.Id -eq $WebFeature.id}) -ne $null)
            {
              #We found that the Feature is active, Lets end up the loop
              $Flag = $True
              break WebAppLoop2 
            }
          }
       }
     }
   if($Flag -eq $False)
   {
     Write-Host "$($WebFeature.DisplayName) is not Active on Any Web!"
   }   
 }

请注意:根据我们使用的网站模板,可能有许多 OOTB 功能保持非活动状态。因此,使用此脚本可以深入了解部署到 SharePoint 2013/SharePoint 2010 环境的自定义功能。

要获取有关在不同范围内激活的功能的报告,请参阅:使用 PowerShell 的 SharePoint 功能使用情况报告

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

取消回复欢迎 发表评论:

关灯