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?
If you are using SharePoint 2013, you may need to delete a service application when you no longer use that service to free up some server resources. You can do this using PowerShell. In this guide, we will show you how to delete a service application in SharePoint!
- Go to SharePoint 2013 Central Administration site
- Navigate to Application Management >> Manage service applications
- On the Manage Service Applications page, Select the Service application that you want to delete.
- Click on the “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 cannot delete a Service application as it may be 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 the 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
Let’s 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:
Type |
Access Services Web Service Application |
Access Services 2010 Web Service Application |
App Management Service Application |
Application Discovery and Load Balancer Service Application |
Business Data Connectivity Service Application |
Excel Services Application Web Service Application |
Machine Translation Service |
Managed Metadata Service |
PerformancePoint Service Application |
PowerPoint Conversion Service Application |
Search Administration Web Service Application |
Search Service Application |
Secure Store Service Application |
Security Token Service Application |
State Service |
Usage and Health Data Collection Service Application |
User Profile Service Application |
Visio Graphics Service Application |
Work Management Service Application |
Word Automation Services |
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