SharePoint Use Cases

31 May, 2010

Remove all Service Applications from SharePoint 2010 farm with PowerShell

Posted by: Toni Frankola In: SharePoint|SharePoint 2010  Bookmark and Share

Well, sometimes things do not go as planned and you need to undo some things you did in SharePoint testing environment or for a client.

As I am currently working on a script to install Service Applications I had a need to remove 10-20 service application from my testing farm automatically.

Here is the script that can do that; it will automatically remove all service applications along with associated data.

Click here to download the script.

cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$seviceApps = Get-SPServiceApplication | Where {$_.TypeName -ne "Security Token Service Application" -and $_.TypeName -ne "Application Discovery and Load Balancer Service Application"}
if($seviceApps -ne $null) {
$seviceApps | ForEach-Object {Remove-SPServiceApplication $_.Id -removedata -confirm:$false}
}
$serviceAppProxies = Get-SpServiceApplicationProxy | Where {$_.TypeName -ne "Application Discovery and Load Balancer Service Application Proxy"}
if($serviceAppProxies -ne $null) {
$serviceAppProxies | ForEach-Object {Remove-SPServiceApplicationProxy $_.Id -removedata -confirm:$false}
}


Documentation Toolkit for SharePoint

Comments

1 | Troubleshooting User Profile Application Service (UPA) « SharePoint and relevant Technologies

March 10th, 2011 at 8:01 am

Avatar

[...] Remove all Service Applications from SharePoint 2010 farm with PowerShell TechNet: Delete a service application The User Profile Synchronization service does not start on a [...]

Comment Form


About

Real-life use case and opinions about collaboration, CRM and web technologies and stuff by Toni Frankola. More...

Toni Frankola - SharePoint MVP Profile

All postings on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer.

Page optimized by WP Minify WordPress Plugin