使用 PowerShell 查找 SharePoint 中超出阈值限制的所有大型列表
要求:查找超过 Web 应用程序资源限制设置中配置的列表视图阈值限制的所有列表。
用于查找所有超出配置阈值限制的大型列表的 PowerShell 脚本:
SharePoint 中较大的列表会消耗更多的资源和性能杀手。作为治理计划的一部分,我们希望找到 SharePoint 环境中所有较大的列表和库。在这篇博文中,我们将向您展示如何使用 PowerShell 查找 SharePoint 网站中的所有大型列表。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get All Web Applications
$WebAppsCollection = Get-SPWebApplication
#Array to Hold Result - PSObjects
$LargeListsResult = @()
foreach($WebApp in $WebAppsCollection)
{
#Get the Throttling Limit of the Web App
$Threshold = $WebApp.MaxItemsPerThrottledOperation
foreach($Site in $WebApp.Sites)
{
foreach($Web in $Site.AllWebs)
{
Write-host "Scanning site:"$Web.URL
foreach($List in $Web.Lists)
{
if($list.ItemCount -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($list.ItemCount)
#Add the object with property to an Array
$LargeListsResult += $Result
}
}
}
}
}
Write-host "Total Number of Large Lists Found:"$LargeListsResult.Count -f Green
#Export the result Array to CSV file
$LargeListsResult | Export-CSV "c:\LargeListData.csv" -NoTypeInformation
该脚本在“C:\LargeListData.CSV”生成一个 CSV 文件,只需在 Microsoft Excel 中打开它,应用一些格式,报告如下所示:

