Quantcast
Channel: CodeSection,代码区,SQL Server(mssql)数据库 技术分享 - CodeSec
Viewing all articles
Browse latest Browse all 3160

DSC Add Local Administrator Group to SQL Server Login (xSQLServerLogin)

$
0
0

One problem I recently faced was, that I tried to use the xSQLServer DSC module to add the local administrator group (Administrators) as a SQL server security login. This should provide access to all local server administrators access to the SQL server application. My first attempt was to use the syntax like server01\Administrators, the DSC configuration looks like this…

xSQLServerLogin LocalAdministrators
{
DependsOn = '[xSqlServerSetup]SQLInstall'
Name = 'server01\Administrators'
LoginType = 'windowsGroup'
SQLServer = $Node.NodeName
SQLInstanceName = $Node.InstanceName
}

This ended in an ugly error like “Create failed for Login ‘server01\Administrators’”. I checked the DSC resource how it works and tried to reproduce the error in ISE. So I ended up with this error locally.


DSC   Add Local Administrator Group to SQL Server Login (xSQLServerLogin)

Trying to add use the SQL Server Management Studio threw the same error.


DSC   Add Local Administrator Group to SQL Server Login (xSQLServerLogin)

Some investigations on the internet didn’t bring any result like here , there were even false answers, telling that it would not work.

The simple trick is not to provide ‘server01\Administrators’, instead use…

‘Builtin\Administrators’ xSQLServerLogin LocalAdministrators
{
DependsOn = '[xSqlServerSetup]SQLInstall'
Name = 'Builtin\Administrators'
LoginType = 'WindowsGroup'
SQLServer = $Node.NodeName
SQLInstanceName = $Node.InstanceName
}

…and voilà the local Administrators group will be added to the SQL Server security login.


DSC   Add Local Administrator Group to SQL Server Login (xSQLServerLogin)

Hope this helps!


Viewing all articles
Browse latest Browse all 3160

Trending Articles