Translate

Wednesday, March 12, 2014

SharePoint - Database Cleanup

From what I've read it seems that one of the common things that can happen when you're working with SharePoint is that you end up with orphaned databases on your SQL server or in SharePoint. Here are some PowerShell commands to help clear that up.
List all databases that are being used by SharePoint:
Get-SPDatabase | Sort-Object disksizerequired -desc | Format-Table Name
Use the returned list to compare with the databases on your SQL server and delete any databases that are not on the list.

List all databases that are being used by SharePoint that are not on the database:
Get-SPDatabase | where {$_.exists -eq $false}
Delete the orphaned databases:
Get-SPDatabase | where {$_.exists -eq $false} | foreach {$_.delete()}

No comments:

Post a Comment

Thank you for commenting!