Home > Powershell, SharePoint, SharePoint 2010 > Remove SharePoint DB without having SQL Management Studio access…

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

Advertisements
  1. orrin
    December 5, 2012 at 20:42

    Thanks a lot!

  2. February 19, 2014 at 20:52

    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.

    • February 20, 2014 at 09:15

      Great tip, I may add that to the post later on, thanks!

      // Thomas

  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: