Skip to content
johlju edited this page Jun 19, 2020 · 2 revisions

SqlServiceAccount

Parameters

Parameter Attribute DataType Description Allowed Values
InstanceName Key String Name of the SQL instance.
ServiceType Key String Type of service being managed. 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 Host name of the SQL Server to manage. 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.
ServiceAccountName Read String Returns the service account username for the service.
VersionNumber Write String The version number for the service, mandatory with IntegrationServices ServiceType

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
        }
    }
}
Clone this wiki locally