Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3bc72fa
`SqlDatabase`: Refactored class-bases resource
johlju Dec 29, 2025
7576b69
Remove MOF-based resource
johlju Dec 29, 2025
06d998d
Remove old unit test
johlju Dec 29, 2025
bd6301e
Implement enum type caching in SqlResourceBase and add corresponding …
johlju Dec 29, 2025
e0727b5
Update CHANGELOG.md to reflect changes in SqlDatabase resource and re…
johlju Dec 29, 2025
d9875c8
Update SqlServerDsc guidelines to clarify DSC properties exclusion fo…
johlju Dec 29, 2025
d556507
Refactor error handling for missing SMO CompatibilityLevel type in Sq…
johlju Dec 29, 2025
5a4460a
Enhance error handling for snapshot isolation in SqlDatabase class
johlju Dec 29, 2025
eaca1f3
Remove unnecessary blank line at the end of SqlDatabase class
johlju Dec 29, 2025
cb4c2db
Update CHANGELOG.md to reflect changes for issue #2174
johlju Dec 29, 2025
2bb09ef
Fix formatting in CHANGELOG.md for consistency and readability
johlju Dec 29, 2025
ff1ed5e
Enhance enum type resolution in SqlResourceBase class to handle Refle…
johlju Dec 29, 2025
b2a3e57
Refine enum type resolution in SqlResourceBase to filter SQL Server a…
johlju Dec 29, 2025
f663c45
Refactor ConvertToSmoEnumType methods in SqlResourceBase for improved…
johlju Dec 29, 2025
5b511d4
Refactor compatibility level handling in SqlDatabase to use ConvertTo…
johlju Dec 29, 2025
23b05fd
Refactor AssertProperties method in SqlDatabase to optimize server ob…
johlju Dec 29, 2025
b0111ab
Refactor ConvertToSmoEnumType method in SqlResourceBase to improve cl…
johlju Dec 29, 2025
9ecf73a
Mock New-SqlDscDataFile and New-SqlDscFileGroup in tests to avoid typ…
johlju Dec 29, 2025
35368c6
Refactor mocks in New-SqlDscDatabaseSnapshot.Tests to use New-Object …
johlju Dec 30, 2025
920e145
Revert to main
johlju Dec 30, 2025
037c1d7
Add TODO comment to New-SqlDscDatabaseSnapshot.Tests for debugging PS…
johlju Dec 30, 2025
7310231
Refactor module name usage in tests and remove unnecessary -Force fla…
johlju Dec 30, 2025
19cecfa
Add DefaultLanguage class and update SqlDatabase to handle DefaultLan…
johlju Dec 30, 2025
2400860
Remove unnecessary -Force flag from Import-Module in integration and …
johlju Dec 30, 2025
1ae0ef4
Handle DefaultLanguage and DefaultFullTextLanguage properties in Test…
johlju Dec 30, 2025
5b67e71
Add RetentionPeriodUnits enum and update SqlDatabase to use it for Ch…
johlju Dec 30, 2025
2a07457
Fix compatibility level check to compare against supported levels dir…
johlju Dec 30, 2025
20b490e
Add MirroringSafetyLevel enum and update SqlDatabase to use it for Mi…
johlju Dec 31, 2025
483c937
Change CompatibilityLevel property to be nullable in SqlDatabase class
johlju Dec 31, 2025
94cbd50
Remove nullable attribute from CompatibilityLevel property and valida…
johlju Dec 31, 2025
8cb2a30
Refactor CompatibilityLevel, MirroringSafetyLevel, and RetentionPerio…
johlju Dec 31, 2025
6d33faf
Remove unused enum type cache from SqlResourceBase class
johlju Jan 1, 2026
bc92ba3
Merge branch 'main' into f/issue-#2174
johlju Jan 1, 2026
85fd4c6
Remove error message for missing SMO type from SqlResourceBase locali…
johlju Jan 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ applyTo: "**"

## Resources
- Database Engine resources: inherit `SqlResourceBase`
- Add `InstanceName`, `ServerName`, and `Credential` to `$this.ExcludeDscProperties`
- `SqlResourceBase` provides: `InstanceName`, `ServerName`, `Credential`, `Reasons`, `GetServerObject()`
- Add any DSC properties whose values cannot be enforced as desired state to `$this.ExcludeDscProperties`
- `SqlResourceBase` provides: `InstanceName`, `ServerName`, `Port`, `Protocol`, `Credential`, `Reasons`, `GetServerObject()`
- Constructor: `MyResourceName() : base () { }` (no $PSScriptRoot parameter)

## SQL Server Interaction
Expand Down
71 changes: 44 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `Protocol` parameter to specify the network protocol when connecting.
- Added `Port` parameter to specify the TCP port number when connecting.
Connection strings now support the format `[protocol:]hostname[\instance][,port]`.
- `SqlDatabase`
- Added new class-based resource to create, modify, or remove databases on a
SQL Server instance. Supports a comprehensive set of database properties
that can be configured with `Set-SqlDscDatabaseProperty`
([issue #2174](https://github.com/dsccommunity/SqlServerDsc/issues/2174)).
- `Install-SqlDscServer`
- Added parameter `AllowDqRemoval` to the `Upgrade` parameter set
([issue #2155](https://github.com/dsccommunity/SqlServerDsc/issues/2155)).
Expand Down Expand Up @@ -91,6 +96,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
later versions.
- Now outputs setup progress when `-Verbose` is passed by using `/QUIETSIMPLE`
instead of `/QUIET`.
- `SqlResourceBase`
- Added the method `ConvertToSmoEnumType()` to convert string values to SMO
enum types at runtime. This method can be used by all resources inheriting
from `SqlResourceBase` and supports a default namespace parameter to avoid
repeating the full type name
([issue #2174](https://github.com/dsccommunity/SqlServerDsc/issues/2174)).

### Changed

Expand Down Expand Up @@ -127,8 +138,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([issue #2376](https://github.com/dsccommunity/SqlServerDsc/issues/2376)).
- `SqlRS`
- Fixed integration tests failing with status code 0 when checking ReportServer
and Reports site accessibility by implementing retry logic (up to 2 minutes) to
handle timing issues where Reporting Services web services are not immediately
and Reports site accessibility by implementing retry logic (up to 2 minutes)
to handle timing issues where Reporting Services web services are not immediately
ready after DSC configuration completes. On final retry attempt with status
code 0, the exception is now re-thrown to provide detailed error diagnostics
([issue #2376](https://github.com/dsccommunity/SqlServerDsc/issues/2376)).
Expand Down Expand Up @@ -182,9 +193,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`System.Boolean` to `Microsoft.SqlServer.Management.Smo.DatabaseScopedConfigurationOnOff`
to match SMO property types and support all valid values (Off, On, Primary)
([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).
- Fixed parameter types for boolean database properties from `System.Boolean` to
`System.Management.Automation.SwitchParameter` to follow PowerShell best practices.
([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).
- Fixed parameter types for boolean database properties from `System.Boolean`
to `System.Management.Automation.SwitchParameter` to follow PowerShell best
practices ([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).
- `New-SqlDscRole`
- Fixed duplicate verbose output by removing manual `Write-Verbose` call, as
`$PSCmdlet.ShouldProcess()` already generates appropriate verbose output
Expand All @@ -194,12 +205,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`System.Boolean` to `Microsoft.SqlServer.Management.Smo.DatabaseScopedConfigurationOnOff`
to match SMO property types and support all valid values (Off, On, Primary)
([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).
- Fixed parameter types for boolean database properties from `System.Boolean` to
`System.Management.Automation.SwitchParameter` to follow PowerShell best practices.
([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).
- Fixed parameter types for boolean database properties from `System.Boolean`
to `System.Management.Automation.SwitchParameter` to follow PowerShell best
practices ([issue #2190](https://github.com/dsccommunity/SqlServerDsc/issues/2190)).

### Removed

- `DSC_SqlDatabase`
- Removed the legacy MOF-based resource. Use the new class-based `SqlDatabase`
resource instead
([issue #2174](https://github.com/dsccommunity/SqlServerDsc/issues/2174)).
- Removed helper function `Get-FilePathMajorVersion` from the SqlServerDsc.Common
module. Refactored usages to use the command `Get-FileVersion` from the
DscResource.Common module instead
Expand All @@ -225,8 +240,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Use the new command `Set-SqlDscDatabaseOwner` to change database ownership instead.
- BREAKING CHANGE: `Set-SqlDscDatabaseProperty`
- Removed parameters `AzureEdition` and `AzureServiceObjective`. Azure SQL Database
service tier and SLO changes should be managed using `Set-AzSqlDatabase` from the
Azure PowerShell module instead. See [issue #2177](https://github.com/dsccommunity/SqlServerDsc/issues/2177).
service tier and SLO changes should be managed using `Set-AzSqlDatabase`
from the Azure PowerShell module instead. See [issue #2177](https://github.com/dsccommunity/SqlServerDsc/issues/2177).
- Removed parameter `DatabaseSnapshotBaseName`. Database snapshots should be
created using the `New-SqlDscDatabaseSnapshot`, or the `New-SqlDscDatabase`
command with the `-DatabaseSnapshotBaseName` parameter.
Expand All @@ -253,10 +268,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
and `DataFile` parameters to allow control over snapshot file placement and
structure ([issue #2341](https://github.com/dsccommunity/SqlServerDsc/issues/2341)).
- Added public command `New-SqlDscFileGroup` to create FileGroup objects for SQL
Server databases. This command simplifies creating FileGroup objects that can be
used with `New-SqlDscDatabase` and other database-related commands. The `Database`
parameter is optional, allowing FileGroup objects to be created standalone and
added to a Database later using `Add-SqlDscFileGroup`.
Server databases. This command simplifies creating FileGroup objects that
can be used with `New-SqlDscDatabase` and other database-related commands.
The `Database` parameter is optional, allowing FileGroup objects to be
created standalone and added to a Database later using `Add-SqlDscFileGroup`.
- Added public command `New-SqlDscDataFile` to create DataFile objects for SQL
Server FileGroups. This command simplifies creating DataFile objects with
specified physical file paths, supporting both regular database files (.mdf, .ndf)
Expand All @@ -279,9 +294,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
database snapshots, enabling control over file placement for snapshots (sparse
files) and custom filegroup/datafile configuration for regular databases
([issue #2341](https://github.com/dsccommunity/SqlServerDsc/issues/2341)).
- Added `IsLedger` parameter to support creating ledger databases at creation time.
Ledger status is read-only after database creation and can only be set when
creating a new database ([issue #2351](https://github.com/dsccommunity/SqlServerDsc/issues/2351)).
- Added `IsLedger` parameter to support creating ledger databases at creation
time. Ledger status is read-only after database creation and can only be set
when creating a new database ([issue #2351](https://github.com/dsccommunity/SqlServerDsc/issues/2351)).
- Added public command `Set-SqlDscDatabaseOwner` to change the owner of a SQL Server
database [issue #2177](https://github.com/dsccommunity/SqlServerDsc/issues/2177).
This command uses the SMO `SetOwner()` method and supports both `ServerObject`
Expand All @@ -300,8 +315,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
to resolve Sysprep compatibility errors [issue #2212](https://github.com/dsccommunity/SqlServerDsc/issues/2212).
- Added integration tests for `Complete-SqlDscImage` command to ensure command
reliability in prepared image installation workflows. The test runs in a separate
pipeline job `Integration_Test_Commands_SqlServer_PreparedImage` with its own CI
worker, and verifies the completion of SQL Server instances prepared using
pipeline job `Integration_Test_Commands_SqlServer_PreparedImage` with its own
CI worker, and verifies the completion of SQL Server instances prepared using
`Install-SqlDscServer` with the `-PrepareImage` parameter. The test includes
scenarios with minimal parameters and various service account/directory
configurations [issue #2212](https://github.com/dsccommunity/SqlServerDsc/issues/2212).
Expand Down Expand Up @@ -1411,7 +1426,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed `Test-IsNumericType` from private functions ([issue #1795](https://github.com/dsccommunity/SqlServerDsc/issues/1795)).
- `Test-IsNumericType` added to _DscResource.Common_ public functions
([issue #87](https://github.com/dsccommunity/DscResource.Common/issues/87)).
- Removed `Test-ServiceAccountRequirePassword` from private functions ([issue #1794](https://github.com/dsccommunity/SqlServerDsc/issues/1794)
- Removed `Test-ServiceAccountRequirePassword` from private functions
([issue #1794](https://github.com/dsccommunity/SqlServerDsc/issues/1794)
- Replaced by `Test-AccountRequirePassword` that was added to _DscResource.Common_
public functions ([issue #93](https://github.com/dsccommunity/DscResource.Common/issues/93)).
- Removed `Assert-RequiredCommandParameter` from private functions ([issue #1796](https://github.com/dsccommunity/SqlServerDsc/issues/1796)).
Expand Down Expand Up @@ -1651,8 +1667,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The deprecated DSC resource SqlServerEndpointState have been removed _(and_
_replaced by a property in [**SqlEndpoint**](https://github.com/dsccommunity/SqlServerDsc/wiki/sqlendpoint))_
([issue #1725](https://github.com/dsccommunity/SqlServerDsc/issues/1725)).
- The deprecated DSC resource SqlServerNetwork have been removed _(and replaced by_
_[**SqlProtocol**](https://github.com/dsccommunity/SqlServerDsc/wiki/sqlprotocol)_
- The deprecated DSC resource SqlServerNetwork have been removed _(and replaced_
_by [**SqlProtocol**](https://github.com/dsccommunity/SqlServerDsc/wiki/sqlprotocol)_
_and [**SqlProtocolTcpIp**](https://github.com/dsccommunity/SqlServerDsc/wiki/sqlprotocoltcpip))_
([issue #1725](https://github.com/dsccommunity/SqlServerDsc/issues/1725)).
- CommonTestHelper
Expand Down Expand Up @@ -2627,8 +2643,8 @@ in a future release.
or `features`.
- Now code coverage is reported to Codecov, and a codecov.yml was added.
- Updated to support DscResource.Common v0.7.1.
- Changed to point to CONTRIBUTING.md on master branch to avoid "404 Page not found"
([issue #1508](https://github.com/dsccommunity/SqlServerDsc/issues/1508)).
- Changed to point to CONTRIBUTING.md on master branch to avoid
"404 Page not found" ([issue #1508](https://github.com/dsccommunity/SqlServerDsc/issues/1508)).
- SqlAGDatabase
- Fixed unit tests that failed intermittently when running unit tests
in PowerShell 7 ([issue #1532](https://github.com/dsccommunity/SqlServerDsc/issues/1532)).
Expand Down Expand Up @@ -3774,8 +3790,8 @@ in a future release.
- Changed the tests so that the local SqlInstall account is added as a member
of the local administrators group.
- Changed the tests so that the local SqlInstall account is added as a member
of the system administrators in SQL Server (Database Engine) - needed for the
xSQLServerAlwaysOnService integration tests.
of the system administrators in SQL Server (Database Engine) - needed for
the xSQLServerAlwaysOnService integration tests.
- Changed so that only one of the Modules-folder for the SQLPS PowerShell module
for SQL Server 2016 is renamed back so it can be used with the integration
tests. There was an issue when more than one SQLPS module was present (see
Expand Down Expand Up @@ -4238,7 +4254,8 @@ in a future release.
- Changes to xSQLServerSetup
- Added a note to the README.md saying that it is not possible to add or remove
features from a SQL Server failover cluster (issue #433).
- Changed so that it reports false if the desired state is not correct (issue #432).
- Changed so that it reports false if the desired state is not correct
(issue #432).
- Added a test to make sure we always return false if a SQL Server failover
cluster is missing features.
- Helper function Connect-SQLAnalysis
Expand Down
2 changes: 2 additions & 0 deletions source/Classes/020.SqlAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ class SqlAudit : SqlResourceBase
# Remove properties that is not an audit property.
'InstanceName'
'ServerName'
'Port'
'Protocol'
'Ensure'
'Force'
'Credential'
Expand Down
Loading
Loading