Skip to content

Commit fc2b89f

Browse files
authored
Set-SqlDscServerPermission: Added support for assigning permissions to a server role (#2061)
- `Set-SqlDscServerPermission` - Added support for assigning permissions to a server role.
1 parent 603095d commit fc2b89f

File tree

4 files changed

+456
-15
lines changed

4 files changed

+456
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
102102
setup.exe ([issue #1171](https://github.com/dsccommunity/SqlServerDsc/issues/1171)).
103103
- SqlRSSetup
104104
- The DSC resource has been refactored into a class-based resource.
105+
- `Set-SqlDscServerPermission`
106+
- Added support for assigning permissions to a server role.
105107

106108
### Fixed
107109

source/Public/Set-SqlDscServerPermission.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<#
22
.SYNOPSIS
3-
Set permission for a login.
3+
Set permission for a server principal.
44
55
.DESCRIPTION
6-
This command sets the permissions for a existing login on a SQL Server
6+
This command sets the permissions for a existing principal on a SQL Server
77
Database Engine instance.
88
99
.PARAMETER ServerObject
@@ -94,14 +94,15 @@ function Set-SqlDscServerPermission
9494
$ConfirmPreference = 'None'
9595
}
9696

97-
$testSqlDscIsLoginParameters = @{
97+
$testSqlDscIsPrincipalParameters = @{
9898
ServerObject = $ServerObject
9999
Name = $Name
100100
}
101101

102-
$isLogin = Test-SqlDscIsLogin @testSqlDscIsLoginParameters
102+
$isLogin = Test-SqlDscIsLogin @testSqlDscIsPrincipalParameters
103+
$isRole = Test-SqlDscIsRole @testSqlDscIsPrincipalParameters
103104

104-
if ($isLogin)
105+
if ($isLogin -or $isRole)
105106
{
106107
# Get the permissions names that are set to $true in the ServerPermissionSet.
107108
$permissionName = $Permission |

source/en-US/SqlServerDsc.strings.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ConvertFrom-StringData @'
2525
IsDatabasePrincipal_DatabaseMissing = The database '{0}' cannot be found.
2626
2727
## Get-SqlDscServerPermission, Set-SqlDscServerPermission
28-
ServerPermission_MissingPrincipal = The principal '{0}' is not a login on the instance '{1}'.
28+
ServerPermission_MissingPrincipal = The principal '{0}' is not a login nor role on the instance '{1}'.
2929
3030
## Set-SqlDscServerPermission
3131
ServerPermission_IgnoreWithGrantForStateDeny = The parameter WithGrant cannot be used together with the state Deny, the parameter WithGrant is ignored.

0 commit comments

Comments
 (0)