Skip to content

SPFarmAdministrators

dscbot edited this page Mar 17, 2023 · 18 revisions

SPFarmAdministrators

Parameters

Parameter Attribute DataType Description Allowed Values
IsSingleInstance Key String Specifies the resource is a single instance, the value must be 'Yes' Yes
Members Write StringArray[] A list of members to set the group to. Those not in this list will be removed
MembersToInclude Write StringArray[] A list of members to add. Members not in this list will be left in the group
MembersToExclude Write StringArray[] A list of members to remove. Members not in this list will be left in the group

Description

Type: Common Requires CredSSP: No

This resource is used to manage the membership of the farm administrators group. There are a number of approaches to how this can be implemented. The "members" property will set a specific list of members for the group, making sure that every user/group in the list is in the group and all others that are members and who are not in this list will be removed. The "MembersToInclude" and "MembersToExclude" properties will allow you to control a specific set of users to add or remove, without changing any other members that are in the group already that may not be specified here, allowing for some manual management outside of this configuration resource.

Examples

Example 1

This example shows how to set a specific list of members for the farm admins group. Any members not in this list will be removed.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPFarmAdministrators LocalFarmAdmins
        {
            IsSingleInstance     = "Yes"
            Members              = @("CONTOSO\user1", "CONTOSO\user2")
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 2

This example shows how certain changes are made to the farm admins groups. Here any members in the MembersToInclude property are added, and members in the MembersToExclude property are removed. Any members that exist in the farm admins group that aren't listed in either of these properties are left alone.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPFarmAdministrators LocalFarmAdmins
        {
            IsSingleInstance     = "Yes"
            MembersToInclude     = @("CONTOSO\user1")
            MembersToExclude     = @("CONTOSO\user2")
            PsDscRunAsCredential = $SetupAccount
        }
    }
}
Clone this wiki locally