Welcome to the navigation

Reprehenderit fugiat in proident, consequat, ut voluptate commodo sit laboris dolore do occaecat consectetur enim aute officia eiusmod veniam, qui esse dolor laborum, eu exercitation. Nisi sint officia sunt magna adipisicing dolore ullamco incididunt ut cillum reprehenderit in tempor est nostrud irure consectetur eiusmod laboris cupidatat elit, ut ad ipsum

Yeah, this will be replaced... But please enjoy the search!

Start a full crawl in SharePoint using PowerShell

I needed a PowerShell script that performs a full crawl with the ability to target a specific content source.

This was the neat result

$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }
if ($snapin -eq $null) {
    Write-Host "[INIT] Loading SharePoint Powershell Snapin"
    Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
 
$searchApp = 
    Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | 
    Where-Object { $_.Name -eq "Local SharePoint sites" }
 
if($searchApp.CrawlState -eq "Idle") {
    Write-Host "CrawlState was Idle, crawling Full" -ForegroundColor Green
    $searchApp.StartFullCrawl()
 
    Do {
        Write-Host "`r#" -ForegroundColor Yellow -NoNewline
        Start-Sleep 5
    } while ($searchApp.CrawlState -ne "Idle")
 
    Write-Host "`nFinsihed crawling" -ForegroundColor Green
 
} else{
    Write-Host "Didn't start crawl, CrawlState was"$searchApp.CrawlState -ForegroundColor Yellow
}

This will print a status while updating (the yellow hash signs)

 

All the params are in the script, enjoy

Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author