-
Notifications
You must be signed in to change notification settings - Fork 226
Credential overview
To support Group Managed Service Accounts (gMSAs) the DSC resource must support it. This also applies to Managed Service Accounts (MSAs).
There are more information about using (g)MSAs with SQL Server
in the article Configure Windows Service Accounts and Permissions in section Managed Service Accounts, Group Managed Service Accounts, and Virtual Accounts
To use a (g)MSA with a DSC resource you should pass the (g)MSA account name in the credential object and use any text string as password.
It is not possible to pass
$nullas password, it is a limitation by how the MOF is generated when encrypting passwords.
If there is a resource that you find that will not work with a (g)MSAs then please submit a new issue. Then the community can work together to support (g)MSAs for that DSC resource too.
For designing a resource for (g)MSAs see the section Group Managed Service Account in the contribution guidelines.
This was discussed in issue #738.
To use a built-in account with a DSC resource you should pass the built-in account name, e.g. 'NT AUTHORITY\NetworkService' in the credential object and use any text string as password.
It is not possible to pass
$nullas password, it is a limitation by how the MOF is generated when encrypting passwords.
If there is a resource that you find that will not work with a built-in account then please submit a new issue. Then the community can work together to support built-in accounts for that DSC resource too.
When using Windows user credentials (i.e., LoginType = 'WindowsUser') with
SqlServerDsc resources, there are important considerations regarding the
username format used in Credential, UserName, and Password
parameters.
The following username formats can be used when creating Windows credentials:
| Format | Example | Works with SQLPS (SQL 2016) | Works with SqlServer module |
|---|---|---|---|
| FQDN (UPN) | user@domain.local |
✅ Yes | ✅ Yes |
| Username only | user |
✅ Yes | ✅ Yes |
| NetBIOS | DOMAIN\user |
❌ No | ✅ Yes |
Important: The NetBIOS format (
DOMAIN\user) does not work with the legacy SQLPS module (SQL Server 2016 and earlier). When using SQLPS, you must use either FQDN format (user@domain.local) or just the username without domain prefix.
-
Prefer FQDN format (
user@domain.local) for maximum compatibility across all SQL Server versions and PowerShell modules. -
Avoid NetBIOS format (
DOMAIN\user) when targeting SQL Server 2016 or environments where SQLPS may be used. - Use the exact username format required by the target environment when passing credentials to commands or DSC resources.
$password = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$username = 'user@company.local'
$credential = [PSCredential]::new($username, $password)
$password = ConvertTo-SecureString 'P@ssw0rd1' -AsPlainText -Force
$username = 'user'
$credential = [PSCredential]::new($username, $password)When using these credentials with SqlServerDsc resources, pass them via the built-in PsDscRunAsCredential, credential or password parameters. This example shows the built-in PsDscRunAsCredential parameter:
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlLogin 'Add_WindowsUser'
{
Ensure = 'Present'
Name = 'CONTOSO\WindowsUser'
LoginType = 'WindowsUser'
ServerName = 'TestServer.company.local'
InstanceName = 'DSC'
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}This section was informed by issue #1223.
- Add-SqlDscFileGroup
- Add-SqlDscNode
- Add-SqlDscRSSslCertificateBinding
- Add-SqlDscRSUrlReservation
- Add-SqlDscTraceFlag
- Assert-SqlDscAgentOperator
- Assert-SqlDscLogin
- Backup-SqlDscDatabase
- Backup-SqlDscRSEncryptionKey
- Complete-SqlDscFailoverCluster
- Complete-SqlDscImage
- Connect-SqlDscDatabaseEngine
- ConvertFrom-SqlDscDatabasePermission
- ConvertFrom-SqlDscServerPermission
- ConvertTo-SqlDscDatabasePermission
- ConvertTo-SqlDscDataFile
- ConvertTo-SqlDscEditionName
- ConvertTo-SqlDscFileGroup
- ConvertTo-SqlDscServerPermission
- Deny-SqlDscServerPermission
- Disable-SqlDscAgentOperator
- Disable-SqlDscAudit
- Disable-SqlDscDatabaseSnapshotIsolation
- Disable-SqlDscLogin
- Disable-SqlDscRsSecureConnection
- Disconnect-SqlDscDatabaseEngine
- Enable-SqlDscAgentOperator
- Enable-SqlDscAudit
- Enable-SqlDscDatabaseSnapshotIsolation
- Enable-SqlDscLogin
- Enable-SqlDscRsSecureConnection
- Get-SqlDscAgentAlert
- Get-SqlDscAgentOperator
- Get-SqlDscAudit
- Get-SqlDscBackupFileList
- Get-SqlDscCompatibilityLevel
- Get-SqlDscConfigurationOption
- Get-SqlDscDatabase
- Get-SqlDscDatabasePermission
- Get-SqlDscDateTime
- Get-SqlDscInstalledInstance
- Get-SqlDscLogin
- Get-SqlDscManagedComputer
- Get-SqlDscManagedComputerInstance
- Get-SqlDscManagedComputerService
- Get-SqlDscPreferredModule
- Get-SqlDscRole
- Get-SqlDscRSConfigFile
- Get-SqlDscRSConfiguration
- Get-SqlDscRSDatabaseInstallation
- Get-SqlDscRSExecutionLog
- Get-SqlDscRSIPAddress
- Get-SqlDscRSLogPath
- Get-SqlDscRSPackage
- Get-SqlDscRSServiceAccount
- Get-SqlDscRSSetupConfiguration
- Get-SqlDscRSSslCertificate
- Get-SqlDscRSSslCertificateBinding
- Get-SqlDscRSUrl
- Get-SqlDscRSUrlReservation
- Get-SqlDscRSVersion
- Get-SqlDscRSWebPortalApplicationName
- Get-SqlDscServerPermission
- Get-SqlDscServerProtocol
- Get-SqlDscServerProtocolName
- Get-SqlDscServerProtocolTcpIp
- Get-SqlDscSetupLog
- Get-SqlDscStartupParameter
- Get-SqlDscTraceFlag
- Grant-SqlDscServerPermission
- Import-SqlDscPreferredModule
- Initialize-SqlDscFailoverCluster
- Initialize-SqlDscImage
- Initialize-SqlDscRebuildDatabase
- Initialize-SqlDscRS
- Install-SqlDscFailoverCluster
- Install-SqlDscPowerBIReportServer
- Install-SqlDscReportingService
- Install-SqlDscServer
- Invoke-SqlDscQuery
- Invoke-SqlDscScalarQuery
- New-SqlDscAgentAlert
- New-SqlDscAgentOperator
- New-SqlDscAudit
- New-SqlDscDatabase
- New-SqlDscDatabaseSnapshot
- New-SqlDscDataFile
- New-SqlDscFileGroup
- New-SqlDscLogin
- New-SqlDscRole
- New-SqlDscRSEncryptionKey
- Remove-SqlDscAgentAlert
- Remove-SqlDscAgentOperator
- Remove-SqlDscAudit
- Remove-SqlDscDatabase
- Remove-SqlDscLogin
- Remove-SqlDscNode
- Remove-SqlDscRole
- Remove-SqlDscRSEncryptedInformation
- Remove-SqlDscRSEncryptionKey
- Remove-SqlDscRSSslCertificateBinding
- Remove-SqlDscRSUnattendedExecutionAccount
- Remove-SqlDscRSUrlReservation
- Remove-SqlDscTraceFlag
- Repair-SqlDscPowerBIReportServer
- Repair-SqlDscReportingService
- Repair-SqlDscServer
- Request-SqlDscRSDatabaseRightsScript
- Request-SqlDscRSDatabaseScript
- Request-SqlDscRSDatabaseUpgradeScript
- Restart-SqlDscRSService
- Restore-SqlDscDatabase
- Restore-SqlDscRSEncryptionKey
- Resume-SqlDscDatabase
- Revoke-SqlDscServerPermission
- Save-SqlDscSqlServerMediaFile
- Set-SqlDscAgentAlert
- Set-SqlDscAgentOperator
- Set-SqlDscAudit
- Set-SqlDscConfigurationOption
- Set-SqlDscDatabaseDefault
- Set-SqlDscDatabaseOwner
- Set-SqlDscDatabasePermission
- Set-SqlDscDatabaseProperty
- Set-SqlDscRSDatabaseConnection
- Set-SqlDscRSDatabaseTimeout
- Set-SqlDscRSServiceAccount
- Set-SqlDscRSSmtpConfiguration
- Set-SqlDscRSSslCertificateBinding
- Set-SqlDscRSUnattendedExecutionAccount
- Set-SqlDscRSUrlReservation
- Set-SqlDscRSVirtualDirectory
- Set-SqlDscServerPermission
- Set-SqlDscStartupParameter
- Set-SqlDscTraceFlag
- Start-SqlDscRSWebService
- Start-SqlDscRSWindowsService
- Stop-SqlDscRSWebService
- Stop-SqlDscRSWindowsService
- Suspend-SqlDscDatabase
- Test-SqlDscAgentAlertProperty
- Test-SqlDscBackupFile
- Test-SqlDscConfigurationOption
- Test-SqlDscDatabaseProperty
- Test-SqlDscIsAgentAlert
- Test-SqlDscIsAgentOperator
- Test-SqlDscIsDatabase
- Test-SqlDscIsDatabasePrincipal
- Test-SqlDscIsLogin
- Test-SqlDscIsLoginEnabled
- Test-SqlDscIsRole
- Test-SqlDscIsSupportedFeature
- Test-SqlDscRSAccessible
- Test-SqlDscRSInitialized
- Test-SqlDscRSInstalled
- Test-SqlDscServerPermission
- Uninstall-SqlDscPowerBIReportServer
- Uninstall-SqlDscReportingService
- Uninstall-SqlDscServer
- Update-SqlDscServer
- Update-SqlDscServerEdition
- Change Report Server Service Account
- Deploy Power BI Report Server
- Setting up a SQL Server AlwaysOn Availability Groups
- Setting up a SQL Server Failover Cluster
- Troubleshooting Report Server
- 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