Skip to content

Commit

Permalink
SqlDatabaseUser: New DSC resource (#1391)
Browse files Browse the repository at this point in the history
- Changes to SqlServerDsc
  - New DSC resource SqlDatabaseUser (issue #846).
    - Adds ability to create database users with more fine-grained control,
      e.g. re-mapping of orphaned logins or a different login. Supports
      creating a user with or without login name, and database users mapped
      to a certificate or asymmetric key.
  - Minor style fixes in unit tests.
- Changes to SqlDatabase
  - Get-TargetResource now correctly return `$null` for the collation property
    when the database does not exist (issue #1395).
  - No longer enforces the collation property if the Collation parameter
    is not part of the configuration (issue #1396).
  - Updated resource description in README.md
  - Fix examples to use `PsDscRunAsCredential` (issue #760).
  - Added integration tests (issue #739).
  - Updated unit tests to the latest template (issue #1068).
  • Loading branch information
pshamus authored and johlju committed Jul 17, 2019
1 parent 2d37a93 commit bb95eb8
Show file tree
Hide file tree
Showing 39 changed files with 3,981 additions and 445 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## Unreleased

- Changes to SqlServerDsc
- New DSC resource SqlDatabaseUser ([issue #846](https://github.com/PowerShell/SqlServerDsc/issues/846)).
- Adds ability to create database users with more fine-grained control,
e.g. re-mapping of orphaned logins or a different login. Supports
creating a user with or without login name, and database users mapped
to a certificate or asymmetric key.
- Changes to helper function Invoke-Query
- Fixes issues in [issue #1355](https://github.com/PowerShell/SqlServerDsc/issues/1355).
- Works together with Connect-SQL now.
Expand All @@ -11,11 +16,21 @@
- Can now pass in 'Microsoft.SqlServer.Management.Smo.Server' object.
- Can also pipe in 'Microsoft.SqlServer.Management.Smo.Server' object.
- Can pipe Connect-SQL | Invoke-Query.
- Added default vaules to Invoke-Query.
- Added default values to Invoke-Query.
- Minor style fixes in unit tests.
- Changes to SqlServerSecureConnection
- Forced $Thumbprint to lowercase to fix [issue #1350](https://github.com/PowerShell/SqlServerDsc/issues/1350).
- Changes to SqlSetup
- Correct minor style violation [issue #1387](https://github.com/PowerShell/SqlServerDsc/issues/1387).
- Changes to SqlDatabase
- Get-TargetResource now correctly return `$null` for the collation property
when the database does not exist ([issue #1395](https://github.com/PowerShell/SqlServerDsc/issues/1395)).
- No longer enforces the collation property if the Collation parameter
is not part of the configuration ([issue #1396](https://github.com/PowerShell/SqlServerDsc/issues/1396)).
- Updated resource description in README.md
- Fix examples to use `PsDscRunAsCredential` ([issue #760](https://github.com/PowerShell/SqlServerDsc/issues/760)).
- Added integration tests ([issue #739](https://github.com/PowerShell/SqlServerDsc/issues/739)).
- Updated unit tests to the latest template ([issue #1068](https://github.com/PowerShell/SqlServerDsc/issues/1068)).

## 13.0.0.0

Expand Down
9 changes: 1 addition & 8 deletions DSCResources/MSFT_SqlDatabase/MSFT_SqlDatabase.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ function Get-TargetResource
$sqlServerObject = Connect-SQL -ServerName $ServerName -InstanceName $InstanceName
if ($sqlServerObject)
{
$sqlDatabaseCollation = $sqlServerObject.Collation

# Check database exists
$sqlDatabaseObject = $sqlServerObject.Databases[$Name]

Expand Down Expand Up @@ -299,11 +297,6 @@ function Test-TargetResource
$getTargetResourceResult = Get-TargetResource @PSBoundParameters
$isDatabaseInDesiredState = $true

if (-not $PSBoundParameters.ContainsKey('Collation'))
{
$Collation = $getTargetResourceResult.Collation
}

switch ($Ensure)
{
'Absent'
Expand All @@ -328,7 +321,7 @@ function Test-TargetResource

$isDatabaseInDesiredState = $false
}
elseif ($getTargetResourceResult.Collation -ne $Collation)
elseif ($PSBoundParameters.ContainsKey('Collation') -and $getTargetResourceResult.Collation -ne $Collation)
{
Write-Verbose -Message (
$script:localizedData.CollationWrong -f $Name, $getTargetResourceResult.Collation, $Collation
Expand Down
Loading

0 comments on commit bb95eb8

Please sign in to comment.