Tuesday, July 28, 2015

Find All Lists which Exceeds List View Lookup Threashold in SharePoint

Requirement:
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 "http://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  
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.



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...