Monday, July 18, 2016

SharePoint 2013: Search Service Application and Common PowerShell Commands


  • Get-SPEnterpriseSearchServiceApplication
    • Returns all Search service application instances in farm
    • Useful for quickly getting the SSA name
    • If only one SSA, returns SSA object that can be used directly in another command. For example: Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication).
  • Get-SPEnterpriseSearchCrawlContentSource
    • To get a listing of all content sources:
      • Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication) | ft -auto
    • To get an instance of a specific content source:
      • $SSACS1= Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication) -Identity 1
      • $SSACS1= Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication) -Identity "Local SharePoint sites"
    • To get the crawl status of all content sources:
      • Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication) | ft name,crawlstatus -auto
    • To get the crawl status of a particular content source;
      • (Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication) -Identity 1).CrawlStatus
    • To stop the crawl of a particular content source:
      • (Get-SPEnterpriseSearchCrawlContentSource -SearchApplication (Get-SPEnterpriseSearchServiceApplication) -Identity 1).StopCrawl
      • Note: this doesn't "force" the crawl process to stop, by, say, terminating it abruptly.  On the contrary, if you run this command, and then quickly navigate to the Central Administration > Search Administration > Manage Content Sources page, you'll see the status change from Crawling Full (or Crawling Incremental) to Stopping and then eventually becoming Idle.
  • Get-SPEnterpriseSearchStatus
    • Returns status of all SSA components.  Basically, shows in text what you see when you navigate to the Search Administration page in Central Administration.
    • If you have just one SSA in the farm, use like so:
      • Get-SPEnterpriseSearchStatus -SearchApplication (Get-SPEnterpriseSearchServiceApplication) | ft -auto
      • Get-SPEnterpriseSearchStatus -SearchApplication (Get-SPEnterpriseSearchServiceApplication) | ft name,state,level,details -auto
  • Get-SPEnterpriseSearchServiceInstance
    • Used without any arguments, returns listing of all servers running a Search service instance - Osearch15, not foundation.
References

No comments: