Friday 21 July 2017

Delete a service application in SharePoint 2013


Step 1

How to Delete a Service Application in SharePoint 2013 using PowerShell

Requirement: Delete SharePoint 2010/2013 Service Application using PowerShell. How to Delete a Service Application in SharePoint 2013:
  • Go to SharePoint 2013 Central Administration site 
  • Navigate to Application Management >> Manage service applications
  • In the Manage Service Applications page, Select the Service application that you want to delete.
  • click Delete button from the Ribbon.
  • You'll get a confirmation dialog, select "Delete data associated with the Service Applications" if you want to delete the service application database. leave this check box if you don't want to delete the Service application's database.
  • Click OK to delete the service application. Once deleted, you'll get the confirmation dialog.
  • 
    
    Delete a Service Application in SharePoint 2013 using PowerShell 
    At times you may have to use PowerShell in scenarios such as you are unable to delete a Service application as it may corrupted.To get rid of a Service Application and remove it completely using PowerShell? Well, Here are the PowerShell cmdlets to Help you!
    
    To remove a service application from PowerShell, use Remove-SPServiceApplication cmdlet.
    Syntax: 
    Remove-SPServiceApplication {Service-App-ID} [-RemoveData]
    E.g.
    Remove-SPServiceApplication "222b3f48-746e-4cd2-a21c-018527554120" -RemoveData
    Remove-SPServiceApplication needs the GUID of the target service application we want to delete, isn't it? So, How to get the Service Application ID? Here is how:
    
    Run: Get-SPServiceApplication cmdlet, It gets you the below result with ID field:
    
    
    
    
    
    PowerShell Script to Delete a SharePoint 2013 Service Application:
    Lets force delete a service application using its display name with PowerShell.
    
    #Display Name
    $DisplayName="Excel Services Application" 
    #Get the Service Application from its Display Name
    $SeviceApp = Get-SPServiceApplication -name $DisplayName 
    #Delete the Service Application
    Remove-SPServiceApplication $SeviceApp -removedata -confirm:$false
    
    
    Get Service Application from Its type name and remove:
    
    
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
    #Type Name String 
    $TypeName="Usage and Health Data Collection Service Application" 
    #Get the Service Application from its Type 
    $SeviceApp = Get-SPServiceApplication | Where {$_.TypeName -eq $TypeName} 
    #Delete the Service Application 
    Remove-SPServiceApplication $SeviceApp -removedata -confirm:$false
    
    
    Here is the Type Name of all service Applications:
    How to delete a service application proxy: 
    If you want to delete the service application proxy alone, use: Remove-SPServiceApplicationProxy cmdlet: 
    
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
    #Type Name String
    $TypeName="Machine Translation Service Proxy" 
    #Get the Service Application Proxy from its Type
    $SeviceAppProxy = Get-SPServiceApplicationProxy | Where {$_.TypeName -eq $TypeName} 
    #Remove the Service Application Proxy
    Remove-SPServiceApplicationProxy $SeviceAppProxy -removedata -confirm:$false

    Step 2

    While deleting the search service application, the page hangs and keeps showing the same messaging like “Deleting the service application…..”. Even if you leave it untouched for hour or two or three like that… nothing happens, it would just hang on from the Central administration.

    In such case, perform the below operations to get them cleaned fully from the Farm.
    1. Get the Search Service application Id – You would get it when you click on the Search Service application from the Manage Service Applications page.

    1. Execute the following STSADM command
      Stsadm -o deleteconfigurationobject -id f1d41cf0-50d0-4fcc-9087-344103757277
    2. Connect to the DataBase Server
    3. Delete the Search Service Application Specific databases (CrawlStoreDB, Application_DB and PropertyStore_DB ) manually.
    Now that the Service application has been cleaned successfully. You could go ahead and configure the Search service application now.
    Note:  STSADM command is still powerful in this case over PowerShell Command. Here is the PowerShell command as an alternative:
    $spapp = Get-SPServiceApplication -Name "Enterprise Search Service Application"
    Remove-SPServiceApplication $spapp -RemoveData
    
    
    References:
    1. How to Delete a Service Application in SharePoint 2013 using PowerShell
    2. Delete a service application in SharePoint 2013
    3. Deleting the SharePoint2010 Search service application