Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
ValidateSet for the Edition property.
- Fixed commands continuing execution after `Assert-ElevatedUser` elevation
errors by setting `$ErrorActionPreference = 'Stop'` [issue #2070](https://github.com/dsccommunity/SqlServerDsc/issues/2070)
- Fixed incorrect array-return syntax in several public `Get-*` commands by
removing a leading comma in return statements which could cause incorrect
output and ScriptAnalyzer warnings: `Get-SqlDscAudit`,
`Get-SqlDscConfigurationOption`, `Get-SqlDscDatabasePermission`,
`Get-SqlDscServerPermission`, and `Get-SqlDscTraceFlag`.
- New-SqlDscDatabase: use `New-ArgumentException` instead of
`New-InvalidArgumentException` for parameter validation errors.

### Added

Expand Down Expand Up @@ -131,6 +138,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved markdown, pester, powershell, and changelog instructions.
- Fixed `Ignore` that seems in edge-cases fail.
- Improved markdown and changelog instructions.
- `RequiredModules.psd1`
- Updated `DscResource.Test` dependency to `latest` (was pinned to `0.17.2`).
- Examples
- `source/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1`
- Removed redundant `$SqlAdministratorCredential` parameter from example
configuration.

## [17.1.0] - 2025-05-22

Expand Down
2 changes: 1 addition & 1 deletion RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.Test' = '0.17.2'
'DscResource.Test' = 'latest'
xDscResourceDesigner = 'latest'

# Build dependencies needed for using the module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ Configuration Example
[System.Management.Automation.PSCredential]
$SqlInstallCredential,

[Parameter()]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential = $SqlInstallCredential,

[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
Expand Down
8 changes: 4 additions & 4 deletions source/Public/Get-SqlDscAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
Get the audit named **MyFileAudit**.

.OUTPUTS
`[Microsoft.SqlServer.Management.Smo.Audit]`
`[Microsoft.SqlServer.Management.Smo.Audit[]]`
Array of SMO Audit objects from the target SQL Server instance.
#>
function Get-SqlDscAudit
{
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Because the rule does not understands that the command returns [System.String[]] when using , (comma) in the return statement')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the rule does not yet support parsing the code when a parameter type is not available. The ScriptAnalyzer rule UseSyntacticallyCorrectExamples will always error in the editor due to https://github.com/indented-automation/Indented.ScriptAnalyzerRules/issues/8.')]
[OutputType([Microsoft.SqlServer.Management.Smo.Audit[]])]
[CmdletBinding()]
Expand Down Expand Up @@ -62,7 +62,7 @@ function Get-SqlDscAudit
{
$auditObject = $ServerObject.Audits[$Name]

if (-not $AuditObject)
if (-not $auditObject)
{
$missingAuditMessage = $script:localizedData.Audit_Missing -f $Name

Expand All @@ -81,6 +81,6 @@ function Get-SqlDscAudit
$auditObject = $ServerObject.Audits
}

return , [Microsoft.SqlServer.Management.Smo.Audit[]] $auditObject
return [Microsoft.SqlServer.Management.Smo.Audit[]] $auditObject
}
}
10 changes: 5 additions & 5 deletions source/Public/Get-SqlDscConfigurationOption.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

.OUTPUTS
`[Microsoft.SqlServer.Management.Smo.ConfigProperty[]]`
Array of SMO ConfigProperty objects representing server configuration options.
#>
function Get-SqlDscConfigurationOption
{
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Because the rule does not understands that the command returns [System.String[]] when using , (comma) in the return statement')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the rule does not yet support parsing the code when a parameter type is not available. The ScriptAnalyzer rule UseSyntacticallyCorrectExamples will always error in the editor due to https://github.com/indented-automation/Indented.ScriptAnalyzerRules/issues/8.')]
[OutputType([Microsoft.SqlServer.Management.Smo.ConfigProperty[]])]
[CmdletBinding()]
Expand All @@ -58,12 +58,12 @@ function Get-SqlDscConfigurationOption
if ($Refresh.IsPresent)
{
# Make sure the configuration option values are up-to-date.
$serverObject.Configuration.Refresh()
$ServerObject.Configuration.Refresh()
}

if ($PSBoundParameters.ContainsKey('Name'))
{
$configurationOption = $serverObject.Configuration.Properties |
$configurationOption = $ServerObject.Configuration.Properties |
Where-Object -FilterScript {
$_.DisplayName -like $Name
}
Expand All @@ -84,10 +84,10 @@ function Get-SqlDscConfigurationOption
}
else
{
$configurationOption = $serverObject.Configuration.Properties.ForEach({ $_ })
$configurationOption = $ServerObject.Configuration.Properties.ForEach({ $_ })
}

return , [Microsoft.SqlServer.Management.Smo.ConfigProperty[]] (
return [Microsoft.SqlServer.Management.Smo.ConfigProperty[]] (
$configurationOption |
Sort-Object -Property 'DisplayName'
)
Expand Down
3 changes: 1 addition & 2 deletions source/Public/Get-SqlDscDatabasePermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#>
function Get-SqlDscDatabasePermission
{
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Because the rule does not understands that the command returns [System.String[]] when using , (comma) in the return statement')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the rule does not yet support parsing the code when a parameter type is not available. The ScriptAnalyzer rule UseSyntacticallyCorrectExamples will always error in the editor due to https://github.com/indented-automation/Indented.ScriptAnalyzerRules/issues/8.')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('AvoidThrowOutsideOfTry', '', Justification = 'Because the code throws based on an prior expression')]
[CmdletBinding()]
Expand Down Expand Up @@ -97,6 +96,6 @@ function Get-SqlDscDatabasePermission
Write-Error -Message $missingDatabaseMessage -Category 'InvalidOperation' -ErrorId 'GSDDP0002' -TargetObject $DatabaseName
}

return , [Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo[]] $getSqlDscDatabasePermissionResult
return [Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo[]] $getSqlDscDatabasePermissionResult
}
}
3 changes: 1 addition & 2 deletions source/Public/Get-SqlDscServerPermission.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
#>
function Get-SqlDscServerPermission
{
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Because the rule does not understands that the command returns [System.String[]] when using , (comma) in the return statement')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the rule does not yet support parsing the code when a parameter type is not available. The ScriptAnalyzer rule UseSyntacticallyCorrectExamples will always error in the editor due to https://github.com/indented-automation/Indented.ScriptAnalyzerRules/issues/8.')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('AvoidThrowOutsideOfTry', '', Justification = 'Because the code throws based on an prior expression')]
[CmdletBinding(DefaultParameterSetName = 'ByName')]
Expand Down Expand Up @@ -196,6 +195,6 @@ function Get-SqlDscServerPermission
Write-Error -Message $missingPrincipalMessage -Category 'InvalidOperation' -ErrorId 'GSDSP0001' -TargetObject $principalName
}

return , [Microsoft.SqlServer.Management.Smo.ServerPermissionInfo[]] $getSqlDscServerPermissionResult
return [Microsoft.SqlServer.Management.Smo.ServerPermissionInfo[]] $getSqlDscServerPermissionResult
}
}
3 changes: 1 addition & 2 deletions source/Public/Get-SqlDscTraceFlag.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#>
function Get-SqlDscTraceFlag
{
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseOutputTypeCorrectly', '', Justification = 'Because the rule does not understands that the command returns [System.UInt32[]] when using , (comma) in the return statement')]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('UseSyntacticallyCorrectExamples', '', Justification = 'Because the rule does not yet support parsing the code when a parameter type is not available. The ScriptAnalyzer rule UseSyntacticallyCorrectExamples will always error in the editor due to https://github.com/indented-automation/Indented.ScriptAnalyzerRules/issues/8.')]
[OutputType([System.UInt32[]])]
[CmdletBinding(DefaultParameterSetName = 'ByServerName')]
Expand Down Expand Up @@ -83,5 +82,5 @@ function Get-SqlDscTraceFlag
$script:localizedData.TraceFlag_Get_DebugReturningTraceFlags -f $MyInvocation.MyCommand, ($traceFlags -join ', ')
)

return , [System.UInt32[]] $traceFlags
return [System.UInt32[]] $traceFlags
}
4 changes: 2 additions & 2 deletions source/Public/New-SqlDscDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function New-SqlDscDatabase
if ($CompatibilityLevel -notin $supportedCompatibilityLevels.$($ServerObject.VersionMajor))
{
$errorMessage = $script:localizedData.Database_InvalidCompatibilityLevel -f $CompatibilityLevel, $ServerObject.InstanceName
New-InvalidArgumentException -ArgumentName 'CompatibilityLevel' -Message $errorMessage
New-ArgumentException -ArgumentName 'CompatibilityLevel' -Message $errorMessage
}
}

Expand All @@ -149,7 +149,7 @@ function New-SqlDscDatabase
if ($Collation -notin $ServerObject.EnumCollations().Name)
{
$errorMessage = $script:localizedData.Database_InvalidCollation -f $Collation, $ServerObject.InstanceName
New-InvalidArgumentException -ArgumentName 'Collation' -Message $errorMessage
New-ArgumentException -ArgumentName 'Collation' -Message $errorMessage
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Describe 'Get-SqlDscServerPermission' -Tag @('Integration_SQL2017', 'Integration
$result = $loginObjects | Get-SqlDscServerPermission

$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType [Microsoft.SqlServer.Management.Smo.ServerPermissionInfo[]]
$result | Should -BeOfType [Microsoft.SqlServer.Management.Smo.ServerPermissionInfo]
$result.Count | Should -BeGreaterThan 1
}
}
Expand Down Expand Up @@ -271,7 +271,7 @@ Describe 'Get-SqlDscServerPermission' -Tag @('Integration_SQL2017', 'Integration
$result = $roleObjects | Get-SqlDscServerPermission

$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType [Microsoft.SqlServer.Management.Smo.ServerPermissionInfo[]]
$result | Should -BeOfType [Microsoft.SqlServer.Management.Smo.ServerPermissionInfo]
$result.Count | Should -BeGreaterThan 1
}
}
Expand Down
24 changes: 0 additions & 24 deletions tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return an empty array' {
$result = Get-SqlDscTraceFlag

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -BeNullOrEmpty

Should -Invoke -CommandName Get-SqlDscStartupParameter -Exactly -Times 1 -Scope It
Expand All @@ -112,8 +110,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return an empty array' {
$result = Get-SqlDscTraceFlag -ServerName 'localhost'

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -BeNullOrEmpty

Should -Invoke -CommandName Get-SqlDscStartupParameter -ParameterFilter {
Expand All @@ -126,8 +122,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return an empty array' {
$result = Get-SqlDscTraceFlag -InstanceName 'SQL2022'

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -BeNullOrEmpty

Should -Invoke -CommandName Get-SqlDscStartupParameter -ParameterFilter {
Expand All @@ -146,8 +140,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {

$result = Get-SqlDscTraceFlag -ServiceObject $mockServiceObject

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -BeNullOrEmpty

Should -Invoke -CommandName Get-SqlDscStartupParameter -Exactly -Times 1 -Scope It
Expand All @@ -168,8 +160,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return the correct values' {
$result = Get-SqlDscTraceFlag

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 1
$result | Should -Contain 4199

Expand All @@ -181,8 +171,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return the correct values' {
$result = Get-SqlDscTraceFlag -ServerName 'localhost'

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 1
$result | Should -Contain 4199

Expand All @@ -196,8 +184,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return the correct values' {
$result = Get-SqlDscTraceFlag -InstanceName 'SQL2022'

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 1
$result | Should -Contain 4199

Expand All @@ -217,8 +203,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {

$result = Get-SqlDscTraceFlag -ServiceObject $mockServiceObject

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 1
$result | Should -Contain 4199

Expand All @@ -240,8 +224,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return the correct values' {
$result = Get-SqlDscTraceFlag

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 2
$result | Should -Contain 4199
$result | Should -Contain 3226
Expand All @@ -254,8 +236,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return the correct values' {
$result = Get-SqlDscTraceFlag -ServerName 'localhost'

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 2
$result | Should -Contain 4199
$result | Should -Contain 3226
Expand All @@ -270,8 +250,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {
It 'Should return the correct values' {
$result = Get-SqlDscTraceFlag -InstanceName 'SQL2022'

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 2
$result | Should -Contain 4199
$result | Should -Contain 3226
Expand All @@ -292,8 +270,6 @@ Describe 'Get-SqlDscTraceFlag' -Tag 'Public' {

$result = Get-SqlDscTraceFlag -ServiceObject $mockServiceObject

Should -ActualValue $result -BeOfType 'System.UInt32[]'

$result | Should -HaveCount 2
$result | Should -Contain 4199
$result | Should -Contain 3226
Expand Down
Loading