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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- `Install-SqlDscServer`
- Added parameter `AllowDqRemoval` to the `Upgrade` parameter set
([issue #2155](https://github.com/dsccommunity/SqlServerDsc/issues/2155)).
- `Test-SqlDscIsSupportedFeature`
- Added DQ, DQC, and MDS features as discontinued starting with SQL Server 2025
(17.x) and later versions ([issue #2380](https://github.com/dsccommunity/SqlServerDsc/issues/2380)).
- Added public command `Get-SqlDscRSPackage` to retrieve package information for
SQL Server Reporting Services or Power BI Report Server. Supports getting version
information from an executable file
Expand Down Expand Up @@ -59,6 +65,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added parameter `-KillActiveSessions` to automatically terminate any active
sessions for a login before dropping it
([issue #2372](https://github.com/dsccommunity/SqlServerDsc/issues/2372)).
- `Invoke-SetupAction`
- Added parameter `AllowDqRemoval` for the `Upgrade` action to allow removal
of Data Quality (DQ) Services during upgrade to SQL Server 2025 (17.x) and
later versions.
- Now outputs setup progress when `-Verbose` is passed by using `/QUIETSIMPLE`
instead of `/QUIET`.

### Changed

Expand Down
33 changes: 29 additions & 4 deletions source/Private/Assert-SetupActionProperties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ function Assert-SetupActionProperties
$SetupAction
)

$setupExecutableFileVersion = $null

<#
Assumes that the MediaPath parameter is always specified as this should
only be called internally by Invoke-SetupAction that have MediaPath as a
mandatory parameter.
#>
$setupExecutableFileVersion = $Property.MediaPath |
Join-Path -ChildPath 'setup.exe' |
Get-FileVersion

if ($Property.ContainsKey('Features'))
{
$setupExecutableFileVersion = $Property.MediaPath |
Join-Path -ChildPath 'setup.exe' |
Get-FileVersion

$Property.Features |
Assert-Feature -ProductVersion $setupExecutableFileVersion.ProductVersion
}
Expand Down Expand Up @@ -238,4 +245,22 @@ function Assert-SetupActionProperties
)
}
}

# The parameter AllowDqRemoval is only allowed for SQL Server 2025 (17.x) and later versions.
if ($Property.ContainsKey('AllowDqRemoval'))
{
$majorVersion = $setupExecutableFileVersion.ProductVersion.Split('.')[0]

if ([System.Int32] $majorVersion -lt 17)
{
$PSCmdlet.ThrowTerminatingError(
[System.Management.Automation.ErrorRecord]::new(
($script:localizedData.InstallSqlServerProperties_AllowDqRemovalInvalidVersion -f $majorVersion),
'ASAP0003', # cSpell: disable-line
[System.Management.Automation.ErrorCategory]::InvalidOperation,
'Command parameters'
)
)
}
}
}
48 changes: 39 additions & 9 deletions source/Private/Invoke-SetupAction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@
.PARAMETER AllowUpgradeForSSRSSharePointMode
See the notes section for more information.

.PARAMETER AllowDqRemoval
Specifies whether to allow removal of Data Quality (DQ) Services during
upgrade to SQL Server 2025 (17.x) and later versions.

.PARAMETER NpEnabled
See the notes section for more information.

Expand Down Expand Up @@ -476,7 +480,7 @@
#>
function Invoke-SetupAction
{
# cSpell: ignore PBDMS Admini AZUREEXTENSION BSTR
# cSpell: ignore PBDMS Admini AZUREEXTENSION BSTR QUIETSIMPLE
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
[OutputType()]
param
Expand Down Expand Up @@ -1210,6 +1214,10 @@ function Invoke-SetupAction
[System.Management.Automation.SwitchParameter]
$AllowUpgradeForSSRSSharePointMode,

[Parameter(ParameterSetName = 'Upgrade')]
[System.Management.Automation.SwitchParameter]
$AllowDqRemoval,

[Parameter(ParameterSetName = 'Install')]
[Parameter(ParameterSetName = 'InstallRole')]
[Parameter(ParameterSetName = 'CompleteImage')]
Expand Down Expand Up @@ -1428,7 +1436,27 @@ function Invoke-SetupAction

$ErrorActionPreference = $originalErrorActionPreference

$setupArgument = '/QUIET /ACTION={0}' -f $setupAction
$quietSimpleSetupActions = @(
'Install'
'PrepareImage'
'CompleteImage'
'InstallFailoverCluster'
'PrepareFailoverCluster'
'CompleteFailoverCluster'
'AddNode'
'RemoveNode'
)

if ($VerbosePreference -eq 'Continue' -and $setupAction -in $quietSimpleSetupActions)
{
$quietMode = '/QUIETSIMPLE'
}
else
{
$quietMode = '/QUIET'
}

$setupArgument = '{0} /ACTION={1}' -f $quietMode, $setupAction

if ($DebugPreference -in @('Continue', 'Inquire'))
{
Expand Down Expand Up @@ -1534,23 +1562,25 @@ function Invoke-SetupAction
# Must be handled differently because the parameter name could not be $PID.
'PRODUCTKEY' # cspell: disable-line
{
# Remove the argument that was added above.
$setupArgument = $setupArgument -replace ' \/{0}' -f $parameterName

$sensitiveValue += $PSBoundParameters.$parameterName

$setupArgument += ' /PID="{0}"' -f $PSBoundParameters.$parameterName
$setupArgument = $setupArgument -replace $parameterName, ('PID="{0}"' -f $PSBoundParameters.$parameterName)

break
}

# Must be handled differently because the argument name shall have an underscore in the argument.
'SQLINSTJAVA' # cspell: disable-line
{
# Remove the argument that was added above.
$setupArgument = $setupArgument -replace ' \/{0}' -f $parameterName
$setupArgument = $setupArgument -replace $parameterName, 'SQL_INST_JAVA'

$setupArgument += ' /SQL_INST_JAVA'
break
}

# Must be handled differently because parameter name does not match the argument name.
'ALLOWDQREMOVAL' # cspell: disable-line
{
$setupArgument = $setupArgument -replace $parameterName, 'IACCEPTDQUNINSTALL' # cspell: disable-line

break
}
Comment thread
johlju marked this conversation as resolved.
Expand Down
8 changes: 8 additions & 0 deletions source/Public/Install-SqlDscServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@
.PARAMETER AllowUpgradeForSSRSSharePointMode
See the notes section for more information.

.PARAMETER AllowDqRemoval
Specifies whether to allow removal of Data Quality (DQ) Services during
upgrade to SQL Server 2025 (17.x) and later versions.

.PARAMETER NpEnabled
See the notes section for more information.

Expand Down Expand Up @@ -994,6 +998,10 @@ function Install-SqlDscServer
[System.Management.Automation.SwitchParameter]
$AllowUpgradeForSSRSSharePointMode,

[Parameter(ParameterSetName = 'Upgrade')]
[System.Management.Automation.SwitchParameter]
$AllowDqRemoval,

[Parameter(ParameterSetName = 'Install')]
[Parameter(ParameterSetName = 'InstallRole')]
[System.Management.Automation.SwitchParameter]
Expand Down
1 change: 1 addition & 0 deletions source/Public/Test-SqlDscIsSupportedFeature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function Test-SqlDscIsSupportedFeature
13 = @('ADV_SSMS', 'SSMS') # cSpell: disable-line
14 = @('RS', 'RS_SHP', 'RS_SHPWFE') # cSpell: disable-line
16 = @('Tools', 'BC', 'CONN', 'BC', 'DREPLAY_CTLR', 'DREPLAY_CLT', 'SNAC_SDK', 'SDK', 'PolyBaseJava', 'SQL_INST_MR', 'SQL_INST_MPY', 'SQL_SHARED_MPY', 'SQL_SHARED_MR') # cSpell: disable-line
17 = @('DQ', 'DQC', 'MDS') # Discontinued in SQL Server 2025 (17.x). See https://learn.microsoft.com/en-us/sql/database-engine/discontinued-database-engine-functionality-in-sql-server
}

<#
Expand Down
1 change: 1 addition & 0 deletions source/en-US/SqlServerDsc.strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ ConvertFrom-StringData @'
## Assert-SetupActionProperties
InstallSqlServerProperties_ASServerModeInvalidValue = The value for ASServerMode is not valid for the setup action {0}.
InstallSqlServerProperties_RsInstallModeInvalidValue = The only valid value for RsInstallMode is 'FilesOnlyMode' when using setup action {0}.
InstallSqlServerProperties_AllowDqRemovalInvalidVersion = The parameter AllowDqRemoval is only allowed for SQL Server 2025 (17.x) and later versions. The media version is {0}.x. (ASAP0004)

## Get-SqlDscManagedComputer
ManagedComputer_GetState = Returning the managed computer object for server {0}.
Expand Down
61 changes: 60 additions & 1 deletion tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ AfterAll {
}

Describe 'Assert-SetupActionProperties' -Tag 'Private' {
BeforeAll {
Mock -CommandName Get-FileVersion -MockWith {
return [PSCustomObject] @{
ProductVersion = '16.0.1000.6'
}
}
}

Context 'When all properties are valid for setup action ''<MockSetupAction>''' -ForEach @(
@{
MockSetupAction = 'Install'
Expand Down Expand Up @@ -100,6 +108,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
It 'Should not throw an exception' {
InModuleScope -Parameters $_ -ScriptBlock {
$null = Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
ValidProperty = 'Value'
} -SetupAction $MockSetupAction -ErrorAction 'Stop'
}
Expand All @@ -118,6 +127,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
$MockParameterName = 'Value'
} -SetupAction 'NotUsed'
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
Expand Down Expand Up @@ -162,6 +172,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
It 'Should throw the correct error' {
InModuleScope -Parameters $_ -ScriptBlock {
{
$MockParameters.MediaPath = $TestDrive
$MockParameters.Role = 'SPI_AS_NewFarm'

Assert-SetupActionProperties -Property $MockParameters -SetupAction 'NotUsed'
Expand All @@ -175,6 +186,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
InModuleScope -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
SecurityMode = 'SQL'
} -SetupAction 'NotUsed'
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
Expand All @@ -188,6 +200,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
MockFileStreamLevel = $_
} -ScriptBlock {
$null = Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
FileStreamLevel = $MockFileStreamLevel
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
}
Expand All @@ -201,6 +214,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
} -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
FileStreamLevel = $MockFileStreamLevel
} -SetupAction 'NotUsed'
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
Expand Down Expand Up @@ -238,6 +252,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
$MockParameterName = 'AccountName'
} -SetupAction 'NotUsed'
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
Expand Down Expand Up @@ -274,7 +289,8 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
It 'Should not throw an exception' {
InModuleScope -Parameters $_ -ScriptBlock {
$null = Assert-SetupActionProperties -Property @{
$MockParameterName = 'AccountName'
MediaPath = $TestDrive
$MockParameterName = 'AccountName'
($MockParameterName -replace 'Account', 'Password') = 'Password'
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
}
Expand Down Expand Up @@ -316,6 +332,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
It 'Should not throw an exception' {
InModuleScope -Parameters $_ -ScriptBlock {
$null = Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
$MockParameterName = 'myMSA$'
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
}
Expand Down Expand Up @@ -553,6 +570,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
ASServerMode = 'PowerPivot'
} -SetupAction $MockSetupAction
} | Should -Throw -ErrorId 'ASAP0001,Assert-SetupActionProperties' # cSpell: disable-line
Expand All @@ -569,10 +587,51 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
RsInstallMode = 'DefaultNativeMode'
} -SetupAction $MockSetupAction
} | Should -Throw -ErrorId 'ASAP0002,Assert-SetupActionProperties' # cSpell: disable-line
}
}
}

Context 'When specifying AllowDqRemoval with SQL Server version older than 2025 (17.x)' {
BeforeAll {
Mock -CommandName Get-FileVersion -MockWith {
return [PSCustomObject] @{
ProductVersion = '16.0.1000.6'
}
}
}

It 'Should throw an exception' {
InModuleScope -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
AllowDqRemoval = $true
} -SetupAction 'Upgrade'
} | Should -Throw -ErrorId 'ASAP0003,Assert-SetupActionProperties' # cSpell: disable-line
}
}
}

Context 'When specifying AllowDqRemoval with SQL Server 2025 (17.x)' {
BeforeAll {
Mock -CommandName Get-FileVersion -MockWith {
return [PSCustomObject] @{
ProductVersion = '17.0.1000.6'
}
}
}

It 'Should not throw an exception' {
InModuleScope -ScriptBlock {
$null = Assert-SetupActionProperties -Property @{
MediaPath = $TestDrive
AllowDqRemoval = $true
} -SetupAction 'Upgrade' -ErrorAction 'Stop'
}
Comment thread
johlju marked this conversation as resolved.
}
}
}
7 changes: 6 additions & 1 deletion tests/Unit/Private/Invoke-SetupAction.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
@{
MockParameterSetName = 'Upgrade'
# cSpell: disable-next
MockExpectedParameters = '-Upgrade -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstanceDir <string>] [-InstanceId <string>] [-ProductKey <string>] [-BrowserSvcStartupType <string>] [-FTUpgradeOption <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-AllowUpgradeForSSRSSharePointMode] [-FailoverClusterRollOwnership <ushort>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
MockExpectedParameters = '-Upgrade -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstanceDir <string>] [-InstanceId <string>] [-ProductKey <string>] [-BrowserSvcStartupType <string>] [-FTUpgradeOption <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-AllowUpgradeForSSRSSharePointMode] [-AllowDqRemoval] [-FailoverClusterRollOwnership <ushort>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
}
@{
MockParameterSetName = 'EditionUpgrade'
Expand Down Expand Up @@ -983,6 +983,11 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
MockParameterValue = $true
MockExpectedRegEx = '\/ALLOWUPGRADEFORSSRSSHAREPOINTMODE=True' # cspell: disable-line
}
@{
MockParameterName = 'AllowDqRemoval'
MockParameterValue = $true
MockExpectedRegEx = '\/IACCEPTDQUNINSTALL\s*' # cspell: disable-line
}
@{
MockParameterName = 'FailoverClusterRollOwnership'
MockParameterValue = 2
Expand Down
7 changes: 6 additions & 1 deletion tests/Unit/Public/Install-SqlDscServer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
@{
MockParameterSetName = 'Upgrade'
# cSpell: disable-next
MockExpectedParameters = '-Upgrade -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstanceDir <string>] [-InstanceId <string>] [-ProductKey <string>] [-BrowserSvcStartupType <string>] [-FTUpgradeOption <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-AllowUpgradeForSSRSSharePointMode] [-FailoverClusterRollOwnership <ushort>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
MockExpectedParameters = '-Upgrade -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstanceDir <string>] [-InstanceId <string>] [-ProductKey <string>] [-BrowserSvcStartupType <string>] [-FTUpgradeOption <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-AllowUpgradeForSSRSSharePointMode] [-AllowDqRemoval] [-FailoverClusterRollOwnership <ushort>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
}
@{
MockParameterSetName = 'EditionUpgrade'
Expand Down Expand Up @@ -785,6 +785,11 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
MockParameterValue = 2
MockExpectedRegEx = '\/FAILOVERCLUSTERROLLOWNERSHIP=2' # cspell: disable-line
}
@{
MockParameterName = 'AllowDqRemoval'
MockParameterValue = $true
MockExpectedRegEx = '\/IACCEPTDQUNINSTALL\s*' # cspell: disable-line
}
) {
BeforeAll {
Mock -CommandName Start-SqlSetupProcess -MockWith {
Expand Down
Loading
Loading