SharePoint Search Service application content sources showing Paused

There may be many reasons for content sources to get into Paused 
Below PowerShell script will help you checks status of Search Service application whether its running or Paused. If paused then returns the detailed information why its paused and asks input from user to resume 

asnp "*sharepoint*"

$searchserviceapps = Get-SPEnterpriseSearchServiceApplication


foreach ($ssa in $searchserviceapps)
{

 Write-Host $ssa  -ForegroundColor Magenta

$band = "0x"

$band0 = "0x0"

Function Details()

    {

$Detail = Read-Host "Do you want to see detailed reasons (Y/N) "

If($Detail -eq "y")

        {
Write-Host "
(band 0x01)          A change in the number of crawl components or crawl databases is in progress.
(band 0x02)          A backup or restore procedure is in progress.
(band 0x04)          A backup of the Volume Shadow Copy Service (VSS) is in progress.
(band 0x08)          One or more servers in the search topology that host query components are offline.
(band 0x20)          One or more crawl databases in the search topology are being rebalanced.
(band 0x40)          One or more link databases in the search topology are being rebalanced.
(band 0x80)          An administrator has manually paused the Search service application.
(band 0x100)         The search index is being deleted.
(band 0x200)         The search index is being repartitioned.

"
}

  }
  Function Resume()

  {
 
  $resume = Read-Host "Do you want to resume Service Service Applicaiton (Y/N) "

  If($resume -eq "y")

  {
  $ssa.Resume()

  Write-Host "Search Service Application is Resumed"
  }
 
  }


Write-Host "Checking if Search Service Application is Paused" -ForegroundColor Green

$SSAStatus = $ssa.IsPaused() -ne 0

If($SSAStatus -eq "True")

{

 Write-Host "Search Service Application is Paused"  -ForegroundColor Yellow


        for ($i=1 ; $i -le 200 ; $i++)

        {
          if($i -lt 10)
             {
 
 $status = ($ssa.IsPaused() -band $band+$i) -ne 0 

     if($status -eq "True")
    {

    Write-Host  "Error in Band value" $band0$i ": " $status  -ForegroundColor "Red"

    Details;

    Resume;

    Break;

    }

  }

           else {
      
            $status = ($ssa.IsPaused() -band $band+$i) -ne 0 

             if($status -eq "True")
                {

                 Write-Host "Error in Band Value: "$band$i ": " $status -ForegroundColor "Red" 
                
                 Details;

                 Resume;
                
                 Break;
            

                    }

                   
                }


        }


}

Else { Write-Host "Search Service Application is not Paused" -ForegroundColor Green }
   
}

Comments

Popular posts from this blog

[Solved ] ...The product key entered does not match any of the Windows images available for installation. Enter a different product key

User Profile Synchronization Service Struck on "Starting" - Fixed