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

[玩转系统] 查找 SharePoint 中超出列表视图查找阈值的所有列表

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

查找 SharePoint 中超出列表视图查找阈值的所有列表


要求:
SharePoint 中的资源限制功能可控制 SharePoint 场上的资源使用情况,以实现最佳使用。我的要求是查找超出 SharePoint 中配置的列表视图查找阈值限制的所有列表。

用于查找超出列表视图查找阈值的所有列表的 PowerShell 脚本:

此脚本扫描 Web 应用程序中的所有列表,并生成一个包含所有列表名称、URL 和查找列的 CSV 文件,其中列表超过在 SharePoint 2013 管理中心站点的 Web 应用程序限制设置中配置的最大计数。


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
#Get the Web Application
$WebApp = Get-SPWebApplication "https://portal.crescent.com"
 
#Array to Hold Result - PSObjects
$ListResults = @()

#Get the Throttling Limit of the Web App
$Threshold = $WebApp.MaxQueryLookupFields
 
    foreach($Site in $WebApp.Sites)
    {
        foreach($Web in $Site.AllWebs)
        {
            Write-host "Scanning site:"$Web.URL
             
            foreach($List in $Web.Lists)
            {
                #Get Number of Lookup Fields
                $LookupFields = $List.Fields | Where { $_.TypeDisplayName -eq "Lookup" -and $_.Hidden -eq $false}
                if($LookupFields.Count -gt $Threshold)
                {
                    $Result = New-Object PSObject
                    $Result | Add-Member NoteProperty Title($list.Title)
                    $Result | Add-Member NoteProperty URL($web.URL)
                    $Result | Add-Member NoteProperty Count($LookupFields.Count)
                     
                    #Add the object with property to an Array
                    $ListResults += $Result
                }
            }
        }
    }

Write-host "Total Number of Lists Exceeding Lookup Threshold:"$ListResults.Count -f Green
#Export the result Array to CSV file
$ListResults | Export-CSV "c:\ListData.csv" -NoTypeInformation

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

取消回复欢迎 发表评论:

关灯