Detach a Content Database from a Web Application

Scenario/Problem: You need to dissociate a content database from a web application without removing the database or deleting the data.

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

The Dismount-SPContentDatabase cmdlet enables you to dissociate the specified content database with the web application without removing the underlying database itself. Use this in conjunction with the Get-SPContentDatabase cmdlet, as shown in Listing 7.5.

Tip

Use the Get-SPContentDatabase cmdlet with the WebApplication parameter to confirm that the content database was dismounted from the web application.

Listing 7.5. Sample Script for Dismounting a Content Database

$database ...

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.