Skip to content

SqlServiceAccount

dscbot edited this page Jun 26, 2020 · 10 revisions

SqlServiceAccount

Parameters

Parameter Attribute DataType Description Allowed Values
InstanceName Key String The name of the SQL Server instance to be configured.
ServiceType Key String The service type to be managed for the instance that is specified in InstanceName. DatabaseEngine, SQLServerAgent, Search, IntegrationServices, AnalysisServices, ReportingServices, SQLServerBrowser, NotificationServices
ServiceAccount Required PSCredential The service account that should be used when running the service.
ServerName Write String The host name of the SQL Server to be configured. Default value is $env:COMPUTERNAME.
RestartService Write Boolean Determines whether the service is automatically restarted when a change to the configuration was needed.
Force Write Boolean Forces the service account to be updated. Useful for password changes. This will cause Set-TargetResource to be run on each consecutive run.
ServiceAccountName Read String Returns the service account username for the service.
VersionNumber Write String The version number for the service type to be managed for the instance that is specified in InstanceName. Mandatory when ServiceType is set to 'IntegrationServices'.

Description

The SqlServiceAccount DSC resource manages the service account for SQL Server services.

Requirements

  • Target machine must have access to the SQLPS PowerShell module or the SqlServer PowerShell module.

Known issues

All issues are not listed here, see here for all open issues.

Examples

Example 1

This example shows how to ensure the SQL Server service on TestServer is running under a user account.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.Management.Automation.PSCredential]
        $ServiceAccountCredential
    )

    Import-DscResource -ModuleName 'SqlServerDsc'

    Node localhost
    {
        SqlServiceAccount 'SetServiceAccount_User'
        {
            ServerName     = 'TestServer'
            InstanceName   = 'MSSQLSERVER'
            ServiceType    = 'DatabaseEngine'
            ServiceAccount = $ServiceAccountCredential
            RestartService = $true
        }
    }
}

Example 2

This example shows how to ensure the SQL Server service on TestServer\DSC is running under a virtual account. Force will cause this account to be set every time the configuration is evaluated. Specifying RestartService will cause the service to be restarted.

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.Management.Automation.PSCredential]
        $ServiceAccountCredential
    )

    Import-DscResource -ModuleName 'SqlServerDsc'

    Node localhost
    {
        SqlServiceAccount 'SetServiceAccount_User'
        {
            ServerName     = 'TestServer'
            InstanceName   = 'DSC'
            ServiceType    = 'DatabaseEngine'
            ServiceAccount = $ServiceAccountCredential
            RestartService = $true
            Force          = $true
        }
    }
}

Home

General

Commands

Clone this wiki locally