Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

Default View Missing - Incremental Search Crawl Stuck - Solution

$
0
0
Problem: SharePoint incremental crawl stuck at a particular point of time - without changing the crawling status from: "Crawling Incremental". No progress in search crawl log. No new items included in search crawl.

Root cause: Default view files / associations missing in some of the lists and libraries. When crawler crawls those lists and libraries it just stuck there! I tried browsing those lists and libraries from "View all Site content" page. Found those libraries were pointing to their settings page, instead of "AllItems.aspx"!

Solution: Create a Default View using PowerShell:
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Get-SPWebApplication, Get-SPWeb cmdlets for MOSS 2007
Function global:Get-SPWebApplication($WebAppURL)
{
return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
}

Function global:Get-SPWeb($url)
{
$site= New-Object Microsoft.SharePoint.SPSite($url)
if($site -ne $null)
{
$web=$site.OpenWeb();
}
return $web
}

#Array to Hold Result - PSObjects
$ResultsColl = @()

$WebApp = Get-SPWebApplication "http://sharepoint.crescent.com"

#Get All site collections of the Web Application
$SitesColl = $webApp.Sites

#Iterate through each site collection/sub-site
foreach($Site in $SitesColl)
{
foreach($web in $site.AllWebs)
{
foreach($list in $web.lists) #Lable for Processing all lists. Otherwise, we'll get collection modified error
{
if($list.hidden -eq $false)
{
if($list.defaultview -eq $null)
{
write-host $web.URL - List Name: $list.title

$ResultItem = New-Object PSObject
$ResultItem | Add-Member -MemberType NoteProperty -name "WebURL" -value $web.URL
$ResultItem | Add-Member -MemberType NoteProperty -Name "ListName" -value $list.title

#Add the object with property to an Array
$ResultsColl += $ResultItem
}
}
}
$web.dispose()
}
$site.dispose()
}

#Process Each List and Create a View in them
#We need to process each list in this separate section
#Because, modifying any object in the collection will thorw: Collection modified exception

foreach($Result in $ResultsColl)
{
$web = Get-SPWeb $Result.WebURL
$list = $web.Lists[$Result.ListName]

#Create the default view
$BaseView = $list.GetUncustomizedViewByBaseViewId(0); # Standard View
$viewColl = $BaseView.ViewFields.ToStringCollection();
$list.Views.Add("Default", $viewColl, $BaseView.Query, $BaseView.RowLimit, $BaseView.Paged, $true);

$web.dispose();
}

#Export the result Array to CSV file
$ResultsColl | Export-CSV "D:\NoDefaultView.csv" -NoTypeInformation

write-host "Script execution has been Completed!"
The above script creates default view on list where its missing. Run the script and initiate a crawl again.

Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>