Delete a Content Database

Scenario/Problem: You want to remove a content database from its web application and delete the actual SQL Server database and data.

Solution: Use the Remove-SPContentDatabase cmdlet with a database variable.

The Remove-SPContentDatabase cmdlet enables you to delete the specified content database. Use this in conjunction with the Get-SPContentDatabase cmdlet, as shown in Listing 7.7.

Listing 7.7. Sample Script for Removing a Content Database

$database = Get-SPContentDatabase-Identity 025b1239-cd62-451e-943d-dff2e0d52ec8Remove-SPContentDatabase $database

Tip

Instead of using the database variable, you can execute Remove-SPContentDatabase by just providing the name of the content database without any parameter entries ...

Get PowerShell™ for SharePoint® 2013 How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.