Skip to content

SPContentDatabase

dscbot edited this page Mar 17, 2023 · 19 revisions

SPContentDatabase

Parameters

Parameter Attribute DataType Description Allowed Values
Name Key String Specifies the name of the content database
DatabaseServer Write String The name of the database server to host the content DB
WebAppUrl Required String The URL of the web application
Enabled Write Boolean Should the database be enabled
WarningSiteCount Write UInt16 Specify the site collection warning limit for the content database
MaximumSiteCount Write UInt16 Specify the site collection maximum limit for the content database
Ensure Write String Present to create this database, absent to ensure it does not exist Present, Absent
UseSQLAuthentication Write Boolean Should SQL Server authentication be used to connect to the database?
DatabaseCredentials Write PSCredential If using SQL authentication, the SQL credentials to use to connect to the instance

Description

Type: Distributed Requires CredSSP: No

This resource is used to add and remove Content Databases to web applications and configure these databases.

NOTE: The DatabaseServer parameter can be null. If provided for an existing content database, it will throw an error when it detects that the specified SQL instance is a different instance that is currently in use. The resource cannot be used to move the database to a different SQL instance.

The default value for the Ensure parameter is Present. When not specifying this parameter, the content database is provisioned.

Examples

Example 1

This example creates a new content database for the specified web application.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPContentDatabase ContentDB
        {
            Name                 = "SharePoint_Content_01"
            DatabaseServer       = "SQL.contoso.local\SQLINSTANCE"
            WebAppUrl            = "http://sharepoint.contoso.com"
            Enabled              = $true
            WarningSiteCount     = 2000
            MaximumSiteCount     = 5000
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 2

This example dismounts a content database from the specified web application. This will not remove the database from SQL server however, only taking it out of the web applications configuration.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPContentDatabase ContentDB
        {
            Name                 = "SharePoint_Content_01"
            DatabaseServer       = "SQL.contoso.local\SQLINSTANCE"
            WebAppUrl            = "http://sharepoint.contoso.com"
            Ensure               = "Absent"
            PsDscRunAsCredential = $SetupAccount
        }
    }
}
Clone this wiki locally