Skip to content
dscbot edited this page Mar 17, 2023 · 20 revisions

SPSite

Parameters

Parameter Attribute DataType Description Allowed Values
Url Key String The URL of the site collection
OwnerAlias Required String The username of the site collection administrator
CompatibilityLevel Write UInt32 The compatibility level of the site
ContentDatabase Write String The name of the content database to create the site in
Description Write String The description to apply to the site collection
HostHeaderWebApplication Write String The URL of the host header web application to create this site in
Language Write UInt32 The language code of the site
Name Write String The display name of the site collection
OwnerEmail Write String The email address of the site collection administrator
QuotaTemplate Write String The quota template to apply to the site collection
SecondaryEmail Write String The secondary site collection admin email address
SecondaryOwnerAlias Write String The secondary site collection admin username
Template Write String The template to apply to the site collection
CreateDefaultGroups Write Boolean Create the default site groups in the site collection
AdministrationSiteType Write String Specifies the type of the site collection: Regular site or tenant administration site TenantAdministration, None

Description

Type: Distributed Requires CredSSP: No

This resource will provision a site collection to the current farm, based on the settings that are passed through. These settings map to the New-SPSite cmdlet and accept the same values and types.

When the site collection exists, not all parameters are checked for being in the desired state. The following parameters are checked: QuotaTemplate, OwnerAlias, SecondaryOwnerAlias, AdministrationSiteType

Since the title of the site collection can be changed by the site collection owner and can result in a conflict between the owner and DSC. Therefore the resource is only using the Name parameter during site creation.

NOTE: When creating Host Header Site Collections, do not use the HostHeader parameter in SPWebApplication. This will set the specified host header on your IIS site and prevent the site from listening for the URL of the Host Header Site Collection. If you want to change the IIS website binding settings, please use the xWebsite resource in the xWebAdministration module.

NOTE2: The CreateDefaultGroups parameter is only used for creating default site groups. It will not remove or change the default groups if they already exist.

NOTE3: AdministrationSiteType is used in combination with the resource SPWebAppClientCallableSettings. The required proxy library must be configured before the administration site type has any effect.

Examples

Example 1

This example creates a site collection with the provided details

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSite TeamSite
        {
            Url                      = "http://sharepoint.contoso.com"
            OwnerAlias               = "CONTOSO\ExampleUser"
            HostHeaderWebApplication = "http://spsites.contoso.com"
            Name                     = "Team Sites"
            Template                 = "STS#0"
            PsDscRunAsCredential     = $SetupAccount
        }
    }
}

Example 2

This example creates a site collection with the provided details

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSite TeamSite
        {
            Url                      = "http://sharepoint.contoso.com"
            OwnerAlias               = "CONTOSO\ExampleUser"
            HostHeaderWebApplication = "http://spsites.contoso.com"
            Name                     = "Team Sites"
            Template                 = "STS#0"
            QuotaTemplate            = "Teamsite"
            PsDscRunAsCredential     = $SetupAccount
        }
    }
}

Example 3

This example creates a site collection with the provided details

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSite TeamSite
        {
            Url                      = "http://sharepoint.contoso.com"
            OwnerAlias               = "CONTOSO\ExampleUser"
            HostHeaderWebApplication = "http://spsites.contoso.com"
            Name                     = "Team Sites"
            Template                 = "STS#0"
            AdministrationSiteType   = "TenantAdministration"
            PsDscRunAsCredential     = $SetupAccount
        }
    }
}
Clone this wiki locally