Attach a Content Database to a Web Application

Scenario/Problem: You need to associate a content database to a web application.

Solution: Use the Mount-SPContentDatabase cmdlet with the WebApplication parameter.

The Mount-SPContentDatabase cmdlet enables you to associate the specified content database with a web application. The command-line entry is similar to the process of creating a new content database because the parameters are Name and WebApplication, as shown in Listing 7.6.

Listing 7.6. Sample Script for Mounting a Content Database

Mount-SPContentDatabase -Name "NewContentDB"-WebApplication "PSWebApp"

A confirmation listing of the content database information displays, just as in creating a new content 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.