-
Notifications
You must be signed in to change notification settings - Fork 224
SqlServiceAccount
| 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 parameter InstanceName. | DatabaseEngine
, SQLServerAgent
, Search
, IntegrationServices
, AnalysisServices
, ReportingServices
, SQLServerBrowser
, NotificationServices
|
| ServiceAccount | Required | PSCredential | The service account that should be used when running the Windows service. | |
| ServerName | Write | String | The host name of the SQL Server to be configured. Default value is the current computer name. | |
| 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 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 parameter InstanceName. Mandatory when parameter ServiceType is set to 'IntegrationServices'
. | |
The SqlServiceAccount
DSC resource manages the service account for SQL
Server services.
- Target machine must have access to the SQLPS PowerShell module or the SqlServer PowerShell module.
- When using the resource against an SQL Server 2022 instance, the module SqlServer v22.0.49-preview or newer must be installed.
All issues are not listed here, see here for all open issues.
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
}
}
}
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
}
}
}
- Add-SqlDscNode
- Add-SqlDscTraceFlag
- Complete-SqlDscFailoverCluster
- Complete-SqlDscImage
- Connect-SqlDscDatabaseEngine
- ConvertFrom-SqlDscDatabasePermission
- ConvertFrom-SqlDscServerPermission
- ConvertTo-SqlDscDatabasePermission
- ConvertTo-SqlDscServerPermission
- Disable-SqlDscAudit
- Disconnect-SqlDscDatabaseEngine
- Enable-SqlDscAudit
- Get-SqlDscAudit
- Get-SqlDscConfigurationOption
- Get-SqlDscDatabasePermission
- Get-SqlDscManagedComputer
- Get-SqlDscManagedComputerService
- Get-SqlDscPreferredModule
- Get-SqlDscServerPermission
- Get-SqlDscStartupParameter
- Get-SqlDscTraceFlag
- Import-SqlDscPreferredModule
- Initialize-SqlDscRebuildDatabase
- Install-SqlDscServer
- Invoke-SqlDscQuery
- New-SqlDscAudit
- Remove-SqlDscAudit
- Remove-SqlDscNode
- Remove-SqlDscTraceFlag
- Repair-SqlDscServer
- Save-SqlDscSqlServerMediaFile
- Set-SqlDscAudit
- Set-SqlDscDatabasePermission
- Set-SqlDscServerPermission
- Set-SqlDscStartupParameter
- Set-SqlDscTraceFlag
- Test-SqlDscIsDatabasePrincipal
- Test-SqlDscIsLogin
- Test-SqlDscIsSupportedFeature
- Uninstall-SqlDscServer
- SqlAG
- SqlAGDatabase
- SqlAgentAlert
- SqlAgentFailsafe
- SqlAgentOperator
- SqlAGListener
- SqlAGReplica
- SqlAlias
- SqlAlwaysOnService
- SqlAudit
- SqlConfiguration
- SqlDatabase
- SqlDatabaseDefaultLocation
- SqlDatabaseMail
- SqlDatabaseObjectPermission
- SqlDatabasePermission
- SqlDatabaseRole
- SqlDatabaseUser
- SqlEndpoint
- SqlEndpointPermission
- SqlLogin
- SqlMaxDop
- SqlMemory
- SqlPermission
- SqlProtocol
- SqlProtocolTcpIp
- SqlReplication
- SqlRole
- SqlRS
- SqlRSSetup
- SqlScript
- SqlScriptQuery
- SqlSecureConnection
- SqlServiceAccount
- SqlSetup
- SqlTraceFlag
- SqlWaitForAG
- SqlWindowsFirewall