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
Thanks a lot!
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.
Great tip, I may add that to the post later on, thanks!
// Thomas