Skip to content

SPSitePropertyBag

Yorick Kuijs edited this page Nov 13, 2020 · 7 revisions

SPSitePropertyBag

Parameters

Parameter Attribute DataType Description Allowed Values
Url Key String The URL of the site collection
Key Key String The key of the SPSite property
Value Write String Value of the SPSite property
Ensure Write String Set to present to ensure the SPSite property exists, or absent to ensure it is removed Present, Absent
InstallAccount Write PSCredential POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsCredential if using PowerShell 5

Description

Type: Distributed Requires CredSSP: No

This resource is used to work with SharePoint Property Bags at the site collection level. The account that runs this resource (PsDscRunAsCredential or InstallAccount) must be a site collection administrator.

The default value for the Ensure parameter is Present. When not specifying this parameter, the property bag is configured.

Examples

Example 1

This example shows how add property bag value in a site collection.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSitePropertyBag Site_APPCodeProperty
        {
            PsDscRunAsCredential = $SetupAccount
            Url    = "https://web.contoso.com"
            Key    = "KeyToAdd"
            Value  = "ValueToAddOrModify"
            Ensure = "Present"
        }
    }
}

Example 2

This example shows how remove a property bag value in a site collection.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSitePropertyBag Site_APPCodeProperty
        {
            PsDscRunAsCredential = $SetupAccount
            Url    = "https://web.contoso.com"
            Key    = "KeyToRemove"
            Ensure = "Absent"
        }
    }
}
Clone this wiki locally