none
How to start crawler from .NET Console Application? RRS feed

  • Question

  • I have implemented the script in powershell to start crawl as startcrawl.ps1.

    I can run this file by open the sharepoint 2010 powershell and type ".\startcrawl.ps1"

    And the crawl start successfully.

    This is the content in ps1 script

     

    $searchapp = Get-SPEnterpriseSearchServiceApplication "FAST Search Content"  

    $contentsource = Get-SPEnterpriseSearchCrawlContentSource "test" -SearchApplication $searchapp  

    $contentsource.StartIncrementalCrawl()

    Anyway, I want to run this script from .NET Console application. But when I executed it.

    It returns that "Get-SPEnterpriseSearchServiceApplication" is not valid cmdlet ...

    Do you have any suggestion?

     


    • Edited by Andy_Chan Tuesday, October 11, 2011 11:11 AM type
    Tuesday, October 11, 2011 11:11 AM

Answers

  • You need to import SharePoint PowerShell snap-in before you can use the cmdlets. Add the following line at the top of your ps1 script:

    Add-PSSnapin Microsoft.SharePoint.Powershell -erroraction SilentlyContinue


    • Marked as answer by Andy_Chan Tuesday, October 11, 2011 12:58 PM
    Tuesday, October 11, 2011 12:57 PM

All replies

  • You need to import SharePoint PowerShell snap-in before you can use the cmdlets. Add the following line at the top of your ps1 script:

    Add-PSSnapin Microsoft.SharePoint.Powershell -erroraction SilentlyContinue


    • Marked as answer by Andy_Chan Tuesday, October 11, 2011 12:58 PM
    Tuesday, October 11, 2011 12:57 PM
  • Thanks Vassili. It works
    • Edited by Andy_Chan Tuesday, October 11, 2011 12:59 PM
    Tuesday, October 11, 2011 12:58 PM