The SqlRole DSC resource is used to create a server role, when Ensure is set to 'Present', or remove a server role, when Ensure is set to 'Absent'. The resource also manages members in both built-in and user created server roles.
When the target role is sysadmin the DSC resource will prevent the user 'sa' from being removed. This is done to keep the DSC resource from throwing an error since SQL Server does not allow this user to be removed.
Source |
|
DSC Resource |
|
Documentation |
-
Target machine must be running Windows Server 2012 or later.
-
Target machine must be running SQL Server Database Engine 2012 or later.
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
Mandatory |
Hashtable[] |
List of SQL roles. |
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
ServerRoleName |
Key |
String |
The name of of SQL Server Database Engine role to add or remove. |
|
InstanceName |
Key |
String |
The name of the SQL Server instance to be configured. |
|
ServerName |
String |
The host name of the SQL Server to be configured. Default value is the current computer name. |
||
Members |
String[] |
The members the server role should have. This parameter will replace all the current server role members with the specified members. |
||
MembersToInclude |
String[] |
The members the server role should include. This parameter will only add members to a server role. Can not be used at the same time as parameter Members. |
||
MembersToExclude |
String[] |
The members the server role should exclude. This parameter will only remove members from a server role. Can only be used when parameter Ensure is set to |
||
Enure |
String |
Determines whether the alias should be added ( |
|
SqlRoles:
Roles:
- ServerRoleName: sysadmin
MembersToInclude: install
InstanceName: MSSQLSERVER
- ServerRoleName: AdminSqlforBI
MembersToInclude:
- CONTOSO\John
- CONTOSO\Kelly
ServerName: sqltest.company.local
InstanceName: DSC