Skip to content

SPFarmPropertyBag

dscbot edited this page Mar 17, 2023 · 16 revisions

SPFarmPropertyBag

Parameters

Parameter Attribute DataType Description Allowed Values
Key Key String The key of the SPFarm property bag
Value Write String Value of the SPfarm property bag
ParameterType Write String Type of the data in the Value parameter Boolean, String, Int32
Ensure Write String Set to present to ensure the SPfarm property exists, or absent to ensure it is removed Present, Absent

Description

Type: Distributed Requires CredSSP: No

This resource is used to work with SharePoint Property Bags at the farm level. The account that runs this resource must be a farm administrator.

The Value parameter must be in string format, but with the ParameterType parameter, you can specify of which data type the data in Value is: String, Boolean or Int32. See the examples for more information.

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 in the current farm.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPFarmPropertyBag 'SetStringValue'
        {
            Key                  = 'FARM_TYPE'
            Value                = 'SearchFarm'
            ParameterType        = 'String'
            Ensure               = 'Present'
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 2

This example shows how add property bag in the current farm.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPFarmPropertyBag 'SetBooleanValue'
        {
            Key                  = 'disableIntranetCalls'
            Value                = 'False'
            ParameterType        = 'Boolean'
            Ensure               = 'Present'
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 3

This example shows how add property bag in the current farm.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPFarmPropertyBag 'SetIntValue'
        {
            Key                  = 'AnswerToEverything'
            Value                = '42'
            ParameterType        = 'Int32'
            Ensure               = 'Present'
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 4

This example shows how remove property bag in the current farm.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPFarmPropertyBag 'RemoveVlaue'
        {
            Key                  = 'KeyToRemove'
            Ensure               = 'Absent'
            PsDscRunAsCredential = $SetupAccount
        }
    }
}
Clone this wiki locally