SharePoint : Lister via PowerShell les informations sur les sources de contenu du Search
Quand on gère le moteur de recherche de SharePoint, on se rend très vite compte que l’interface est riche mais manque un peu de répondant (surtout quand vous commencez à dépasser les 20 Sources de contenu).
Voila donc un script PowerShell pour afficher les informations sur chaque source de contenu avec les informations de planification :
| function Get-Crawl-Information-Schedule([string]$SiteCollectionURL) { [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") > $null $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) Write-Host "SiteCollectionURL", $SiteCollectionURL $context = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($site) $site.Dispose() $sspcontent = new-object Microsoft.Office.Server.Search.Administration.Content($context) $sspContentSources = $sspcontent.ContentSources foreach ($cs in $sspContentSources) { Write-Host " ------------------------------------------------------ " Write-Host "NAME: ", $cs.Name, " - ID: ", $cs.Id, " - CrawlStatus: ", $cs.CrawlStatus $myFullCrawlschedule = $cs.FullCrawlSchedule Write-Host "Full Crawl Schedule Description: ", $myFullCrawlschedule.Description $myIncrementalschedule = $cs.IncrementalCrawlSchedule Write-Host "Incremental Crawl Schedule Description: ", $myIncrementalschedule.Description } Write-Host " ------------------------------------------------------ " } Get-Crawl-Information-Schedule “http://search.xxxx” |
Un second script permet de faire un lancement ou stop des crawls de notre search server :
| function Start-Stop-All-Crawl([string]$SiteCollectionURL, [string]$FullIncrementalorStop) { [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.Search") > $null $site = new-object Microsoft.SharePoint.SPSite($SiteCollectionURL) Write-Host "SiteCollectionURL", $SiteCollectionURL $context = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($site) $site.Dispose() $sspcontent = new-object Microsoft.Office.Server.Search.Administration.Content($context) $sspContentSources = $sspcontent.ContentSources Write-Host "Total of Content Sources: ", $sspContentSources.Count foreach ($cs in $sspContentSources) { Write-Host "NAME: ", $cs.Name, " - ID: ", $cs.Id switch($FullIncrementalorStop) { "full" { Write-Host "Start Full Crawl" $cs.StartFullCrawl() Write-Host "Full Crawl Started" } "incremental" { Write-Host "Start Incremental Crawl" $cs.StartIncrementalCrawl() Write-Host "Incremental Crawl Started" } default { Write-Host "Stop Crawl" $cs.StopCrawl() Write-Host "Crawl Stopped" } } } } Start-Stop-All-Crawl “http://search.xxxxx” "full” |
Il vous reste donc à adapter ce type de script pour votre besoin pour par exemple, redéfinir les planifications.
Toutes les propriétés de ces objets sont disponibles ici :
Romelard Fabrice [MVP]
Ce post vous a plu ? Ajoutez le dans vos favoris pour ne pas perdre de temps à le retrouver le jour où vous en aurez besoin :