Skip to content
dscbot edited this page Nov 11, 2023 · 1 revision

xServiceSet

Parameters

Parameter Attribute DataType Description Allowed Values
Name Required System.String[] An array of the names of the services to configure.
Ensure Write System.String Specifies whether or not the set of services should exist.

Set this property to Present to modify a set of services. Set this property to Absent to remove a set of services. | Present, Absent | | StartupType | Write | System.String | The startup type each service in the set should have. | Automatic, Manual, Disabled | | BuiltInAccount | Write | System.String | The built-in account each service in the set should start under.

Cannot be specified at the same time as Credential.

The user account specified by this property must have access to the service executable paths in order to start the services. | LocalSystem, LocalService, NetworkService | | State | Write | System.String | The state each service in the set should be in. From the default value defined in xService, the default will be Running. | Running, Stopped, Ignore | | Credential | Write | System.Management.Automation.PSCredential | The credential of the user account each service in the set should start under.

Cannot be specified at the same time as BuiltInAccount.

The user specified by this credential will automatically be granted the Log on as a Service right. The user account specified by this property must have access to the service executable paths in order to start the services. | |

Description

Provides a mechanism to configure and manage multiple xService resources with common settings but different names. This resource can only modify or delete existing services. It cannot create services.

Examples

Example 1

#Requires -Module xPSDesiredStateConfiguration

<#
    .SYNOPSIS
        Sets the Secure Socket Tunneling Protocol and DHCP Client services to
        run under the built-in account LocalService.

    .DESCRIPTION
        Sets the Secure Socket Tunneling Protocol and DHCP Client services to
        run under the built-in account LocalService.

        The current state of the services are ignored.

    .EXAMPLE
        xServiceSet_EnsureBuiltInAccount_Config

        Compiles a configuration that sets the Secure Socket Tunneling Protocol
        and DHCP Client services to run under the built-in account LocalService.
#>
Configuration xServiceSet_EnsureBuiltInAccount_Config
{
    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xServiceSet EnsureBuiltInAccount
        {
            Name           = @('SstpSvc', 'Dhcp')
            Ensure         = 'Present'
            BuiltInAccount = 'LocalService'
            State          = 'Ignore'
        }
    }
}

Example 2

#Requires -Module xPSDesiredStateConfiguration

<#
    .DESCRIPTION
        Configuration that starts one or more services.

    .PARAMETER Name
        The name of one or more the Windows services to start.

    .EXAMPLE
        xServiceSet_StartServices_Config -Name @('Dhcp', 'MpsSvc')

        Compiles a configuration that ensures that the DHCP Client and
        Windows Firewall services are running.

    .EXAMPLE
        Start-AzureRmAutomationDscCompilationJob -ResourceGroupName '<resource-group>' -AutomationAccountName '<automation-account>' -ConfigurationName 'xServiceSet_StartServicesConfig' -Parameters @{ Name = @('Dhcp', 'MpsSvc') }

        Compiles a configuration in Azure Automation that ensures that the
        DHCP Client and Windows Firewall services are running.

        Replace the <resource-group> and <automation-account> with correct values.
#>
Configuration xServiceSet_StartServices_Config
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String[]]
        $Name
    )

    Import-DscResource -ModuleName xPSDesiredStateConfiguration

    Node localhost
    {
        xServiceSet StartServices
        {
            Name   = $Name
            Ensure = 'Present'
            State  = 'Running'
        }
    }
}