2

I have a corrupted Search service in SharePoint 2013. I'm trying to delete it using PowerShell.

$P = Get-SPServiceApplication -identity "myGuid"
Remove-SPServiceApplication $P -RemoveData -confirm:$false

The problem is that the delete process takes a very long time. I waited for a whole day and yet the command has still not finished. However, I foundthat the following databases get deleted:

  • SearchDB
  • Search_AnalyticsReportingStore
  • Search_CrawlStore
  • Search_LinkStore

But the Search Service Application still exist in CA and the app pool for Search Service still remain.

How I can delete a corrupted Search Service Application?

What I have tried so far:

  1. Stop search service, timer job and clear the configuration cache.
  2. Reboot the machine.

$spapp = Get-SPServiceApplication -Name "Search Service Application"

When I ran the above cmd I get the following error:

format-default : Exception has been thrown by the target of an invocation.
    + CategoryInfo          : NotSpecified: (:) [format-default], TargetInvocationException
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Microsoft.PowerShell.Commands.FormatDefaultCommand 

The logs said that it could not connect to the databases which was already deleted.

5

Once I ran into the same problem long ago. The command

stsadm -o deleteconfigurationobject -id “your search service application ID” 

helped. I was told that the PowerShell command

Remove-SPServiceApplication -id “your search service application ID” -RemoveData 

would not always do the trick because it's weaker than the stsadm command.

Source

  • Thanks. I have tried both options but it took more than 5 hours to delete and yet to completed?. how long did it takes you? – Supermode Aug 16 '17 at 0:28
  • thanks. it worked using the first option when i tried the second time by clearing configuration cache. – Supermode Aug 16 '17 at 1:57
  • In what order did you clear the configuration cache? Did you stop the timer service, run remove the xml files and then allow them to rebuild again before running stsadm? – VB Did Nothing Wrong Mar 25 '18 at 22:56
1

I had a similar issue with not being able to delete a Search Service. I tried many, many things. Finally I noticed a message like:

SPTimerJobAsyncResult 'cc0b6fbe-9251-4a7d-b824-864195ad6abc': Timer job has not completed.  Blocking until job completes.

In ULS after running either Remove-SPServiceApplication or stsadm.

This timer service belonged to my Search Service Administration. It seemed to be constantly in the middle of doing something and not getting anywhere.

So I tried running:

Stop-Service SPTimerV4
Start-Service SPTimerV4

A couple of times while Remove-SPServiceApplication was running. Eventually this did the trick and my Search Service Application was successfully removed. I ommitted the RemoveData option so I did have to delete the databases after it completed. This is probably not a particularly safe thing to do so absolutely make sure you have a full Farm backup you can restore to.

Also, be very very careful about running stsadm -o deleteconfigurationobject, I have read multiple warnings that Microsoft do not support its use outside of supervision by Microsoft support, and never using this in a production environment, and I did run into an experience where I had to Restore-SPFarm after trying to use this approach for removing the Search Service.

Edit - in retrospect, and after seeing some other issues pop up in the farm this may have also been due to timer service instance objects being disabled post-upgrade - there is a script to re-enable these, see:

https://blogs.msdn.microsoft.com/tehnoonr/2011/09/07/sharepoint-server-2010-timer-jobs-not-functioning-after-applying-updates/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.