Skip to content

SPService

dscbot edited this page Mar 17, 2023 · 4 revisions

SPService

Parameters

Parameter Attribute DataType Description Allowed Values
Name Key String The name of the service instance to manage
Ensure Write String Present to ensure the service runs in the farm, or absent to ensure it is stopped Present, Absent

Description

Type: Distributed Requires CredSSP: No

This resource is used to specify if a specific service should be provisioned (Ensure = "Present") or deprovisioned (Ensure = "Absent") in the MinRole configuration of the farm. The name is the display name of the service as shown in the "Services in Farm" page in Central Admin: http://[central_admin_url]/_admin/FarmServices.aspx

The default value for the Ensure parameter is Present. When not specifying this parameter, the service instance is started.

Examples

Example 1

This example shows how to ensure that the Microsoft SharePoint Foundation Sandboxed Code Service is provisioned as a MinRole in the farm.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPService 'Microsoft SharePoint Foundation Sandboxed Code Service'
        {
            Name                 = 'Microsoft SharePoint Foundation Sandboxed Code Service'
            Ensure               = 'Present'
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Example 2

This example shows how to ensure that the Microsoft SharePoint Foundation Sandboxed Code Service is deprovisioned as a MinRole in the farm.

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

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPService 'Microsoft SharePoint Foundation Sandboxed Code Service'
        {
            Name                 = 'Microsoft SharePoint Foundation Sandboxed Code Service'
            Ensure               = 'Absent'
            PsDscRunAsCredential = $SetupAccount
        }
    }
}
Clone this wiki locally