Wednesday, October 21, 2015

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.
     how to delete service application in powershell sharepoint 2013
  • 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.
     sharepoint delete service application powershell force
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.
Remove-SPServiceApplication {Service-App-ID} [-RemoveData]
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:

delete service application using powershell sharepoint

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:
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
All above cmdlets removes service application and its proxy!

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

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...