Remove SharePoint DB without having SQL Management Studio access…


Remove SharePoint DB using PowerShell

Just a quick tip that can help a lot in some situations, when in the situation when you for example have deleted a service application and the DB’s are still there, the DBA’s have all left and you have no way of connecting to SQL with a management tool…

This is what you can do, given that you have the permissions…(high?)

Get-SPDatabase
(Will list all databases used by SharePoint, Name and GUID and Type.)

$DatabaseToDelete = Get-SPDatabase <GUID of the database you need to get rid of>
(Load the database as a SPDatabase object)

$DatabaseToDelete.Delete()
(It’s now gone…)

Thats all there is to it.

Enjoy!

Regards

Twitter | Technet Profile | LinkedIn

3 thoughts on “Remove SharePoint DB without having SQL Management Studio access…

  1. You can also do something like: Get-SPDatabase | ? {$_.name -like “*[keyword]*”} | % {$_.delete()} if you have a naming standard on all DBs and can identify multiple through a query.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s