Find All Lists which Exceeds List View Lookup threshold in SharePoint

Resource throttling feature in SharePoint controls resource usage on SharePoint Farm for optimum usage. My requirement was to find all lists which are exceeding configured list view lookup threshold limit in SharePoint.

PowerShell script to find All Lists which are Exceeding List View Lookup threshold:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web Application
$WebApp = Get-SPWebApplication ""
#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

This script produces a CSV file with all List Name, their URLs and number of lookup columns where the list exceeds maximum count configured in web application throttling settings in SharePoint 2013 central administration site.

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply