Find All Lists which Exceeds List View Lookup Threashold 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 threashold limit in SharePoint.

PowerShell script to find All Lists which are Exceeding List View Lookup Threashold:
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.

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.