Skip to content

Commit 82bd423

Browse files
authored
Support SQL Server 2025 setup arguments and discontinued feature (#2381)
1 parent fdc54b9 commit 82bd423

10 files changed

+188
-16
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
### Added
99

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

6375
### Changed
6476

source/Private/Assert-SetupActionProperties.ps1

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,19 @@ function Assert-SetupActionProperties
4242
$SetupAction
4343
)
4444

45+
$setupExecutableFileVersion = $null
46+
47+
<#
48+
Assumes that the MediaPath parameter is always specified as this should
49+
only be called internally by Invoke-SetupAction that have MediaPath as a
50+
mandatory parameter.
51+
#>
52+
$setupExecutableFileVersion = $Property.MediaPath |
53+
Join-Path -ChildPath 'setup.exe' |
54+
Get-FileVersion
55+
4556
if ($Property.ContainsKey('Features'))
4657
{
47-
$setupExecutableFileVersion = $Property.MediaPath |
48-
Join-Path -ChildPath 'setup.exe' |
49-
Get-FileVersion
50-
5158
$Property.Features |
5259
Assert-Feature -ProductVersion $setupExecutableFileVersion.ProductVersion
5360
}
@@ -238,4 +245,22 @@ function Assert-SetupActionProperties
238245
)
239246
}
240247
}
248+
249+
# The parameter AllowDqRemoval is only allowed for SQL Server 2025 (17.x) and later versions.
250+
if ($Property.ContainsKey('AllowDqRemoval'))
251+
{
252+
$majorVersion = $setupExecutableFileVersion.ProductVersion.Split('.')[0]
253+
254+
if ([System.Int32] $majorVersion -lt 17)
255+
{
256+
$PSCmdlet.ThrowTerminatingError(
257+
[System.Management.Automation.ErrorRecord]::new(
258+
($script:localizedData.InstallSqlServerProperties_AllowDqRemovalInvalidVersion -f $majorVersion),
259+
'ASAP0003', # cSpell: disable-line
260+
[System.Management.Automation.ErrorCategory]::InvalidOperation,
261+
'Command parameters'
262+
)
263+
)
264+
}
265+
}
241266
}

source/Private/Invoke-SetupAction.ps1

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@
294294
.PARAMETER AllowUpgradeForSSRSSharePointMode
295295
See the notes section for more information.
296296
297+
.PARAMETER AllowDqRemoval
298+
Specifies whether to allow removal of Data Quality (DQ) Services during
299+
upgrade to SQL Server 2025 (17.x) and later versions.
300+
297301
.PARAMETER NpEnabled
298302
See the notes section for more information.
299303
@@ -476,7 +480,7 @@
476480
#>
477481
function Invoke-SetupAction
478482
{
479-
# cSpell: ignore PBDMS Admini AZUREEXTENSION BSTR
483+
# cSpell: ignore PBDMS Admini AZUREEXTENSION BSTR QUIETSIMPLE
480484
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'High')]
481485
[OutputType()]
482486
param
@@ -1210,6 +1214,10 @@ function Invoke-SetupAction
12101214
[System.Management.Automation.SwitchParameter]
12111215
$AllowUpgradeForSSRSSharePointMode,
12121216

1217+
[Parameter(ParameterSetName = 'Upgrade')]
1218+
[System.Management.Automation.SwitchParameter]
1219+
$AllowDqRemoval,
1220+
12131221
[Parameter(ParameterSetName = 'Install')]
12141222
[Parameter(ParameterSetName = 'InstallRole')]
12151223
[Parameter(ParameterSetName = 'CompleteImage')]
@@ -1428,7 +1436,27 @@ function Invoke-SetupAction
14281436

14291437
$ErrorActionPreference = $originalErrorActionPreference
14301438

1431-
$setupArgument = '/QUIET /ACTION={0}' -f $setupAction
1439+
$quietSimpleSetupActions = @(
1440+
'Install'
1441+
'PrepareImage'
1442+
'CompleteImage'
1443+
'InstallFailoverCluster'
1444+
'PrepareFailoverCluster'
1445+
'CompleteFailoverCluster'
1446+
'AddNode'
1447+
'RemoveNode'
1448+
)
1449+
1450+
if ($VerbosePreference -eq 'Continue' -and $setupAction -in $quietSimpleSetupActions)
1451+
{
1452+
$quietMode = '/QUIETSIMPLE'
1453+
}
1454+
else
1455+
{
1456+
$quietMode = '/QUIET'
1457+
}
1458+
1459+
$setupArgument = '{0} /ACTION={1}' -f $quietMode, $setupAction
14321460

14331461
if ($DebugPreference -in @('Continue', 'Inquire'))
14341462
{
@@ -1534,23 +1562,25 @@ function Invoke-SetupAction
15341562
# Must be handled differently because the parameter name could not be $PID.
15351563
'PRODUCTKEY' # cspell: disable-line
15361564
{
1537-
# Remove the argument that was added above.
1538-
$setupArgument = $setupArgument -replace ' \/{0}' -f $parameterName
1539-
15401565
$sensitiveValue += $PSBoundParameters.$parameterName
15411566

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

15441569
break
15451570
}
15461571

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

1553-
$setupArgument += ' /SQL_INST_JAVA'
1577+
break
1578+
}
1579+
1580+
# Must be handled differently because parameter name does not match the argument name.
1581+
'ALLOWDQREMOVAL' # cspell: disable-line
1582+
{
1583+
$setupArgument = $setupArgument -replace $parameterName, 'IACCEPTDQUNINSTALL' # cspell: disable-line
15541584

15551585
break
15561586
}

source/Public/Install-SqlDscServer.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@
276276
.PARAMETER AllowUpgradeForSSRSSharePointMode
277277
See the notes section for more information.
278278
279+
.PARAMETER AllowDqRemoval
280+
Specifies whether to allow removal of Data Quality (DQ) Services during
281+
upgrade to SQL Server 2025 (17.x) and later versions.
282+
279283
.PARAMETER NpEnabled
280284
See the notes section for more information.
281285
@@ -994,6 +998,10 @@ function Install-SqlDscServer
994998
[System.Management.Automation.SwitchParameter]
995999
$AllowUpgradeForSSRSSharePointMode,
9961000

1001+
[Parameter(ParameterSetName = 'Upgrade')]
1002+
[System.Management.Automation.SwitchParameter]
1003+
$AllowDqRemoval,
1004+
9971005
[Parameter(ParameterSetName = 'Install')]
9981006
[Parameter(ParameterSetName = 'InstallRole')]
9991007
[System.Management.Automation.SwitchParameter]

source/Public/Test-SqlDscIsSupportedFeature.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function Test-SqlDscIsSupportedFeature
5454
13 = @('ADV_SSMS', 'SSMS') # cSpell: disable-line
5555
14 = @('RS', 'RS_SHP', 'RS_SHPWFE') # cSpell: disable-line
5656
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
57+
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
5758
}
5859

5960
<#

source/en-US/SqlServerDsc.strings.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ ConvertFrom-StringData @'
162162
## Assert-SetupActionProperties
163163
InstallSqlServerProperties_ASServerModeInvalidValue = The value for ASServerMode is not valid for the setup action {0}.
164164
InstallSqlServerProperties_RsInstallModeInvalidValue = The only valid value for RsInstallMode is 'FilesOnlyMode' when using setup action {0}.
165+
InstallSqlServerProperties_AllowDqRemovalInvalidVersion = The parameter AllowDqRemoval is only allowed for SQL Server 2025 (17.x) and later versions. The media version is {0}.x. (ASAP0004)
165166
166167
## Get-SqlDscManagedComputer
167168
ManagedComputer_GetState = Returning the managed computer object for server {0}.

tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ AfterAll {
4747
}
4848

4949
Describe 'Assert-SetupActionProperties' -Tag 'Private' {
50+
BeforeAll {
51+
Mock -CommandName Get-FileVersion -MockWith {
52+
return [PSCustomObject] @{
53+
ProductVersion = '16.0.1000.6'
54+
}
55+
}
56+
}
57+
5058
Context 'When all properties are valid for setup action ''<MockSetupAction>''' -ForEach @(
5159
@{
5260
MockSetupAction = 'Install'
@@ -100,6 +108,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
100108
It 'Should not throw an exception' {
101109
InModuleScope -Parameters $_ -ScriptBlock {
102110
$null = Assert-SetupActionProperties -Property @{
111+
MediaPath = $TestDrive
103112
ValidProperty = 'Value'
104113
} -SetupAction $MockSetupAction -ErrorAction 'Stop'
105114
}
@@ -118,6 +127,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
118127
InModuleScope -Parameters $_ -ScriptBlock {
119128
{
120129
Assert-SetupActionProperties -Property @{
130+
MediaPath = $TestDrive
121131
$MockParameterName = 'Value'
122132
} -SetupAction 'NotUsed'
123133
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -162,6 +172,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
162172
It 'Should throw the correct error' {
163173
InModuleScope -Parameters $_ -ScriptBlock {
164174
{
175+
$MockParameters.MediaPath = $TestDrive
165176
$MockParameters.Role = 'SPI_AS_NewFarm'
166177

167178
Assert-SetupActionProperties -Property $MockParameters -SetupAction 'NotUsed'
@@ -175,6 +186,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
175186
InModuleScope -ScriptBlock {
176187
{
177188
Assert-SetupActionProperties -Property @{
189+
MediaPath = $TestDrive
178190
SecurityMode = 'SQL'
179191
} -SetupAction 'NotUsed'
180192
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -188,6 +200,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
188200
MockFileStreamLevel = $_
189201
} -ScriptBlock {
190202
$null = Assert-SetupActionProperties -Property @{
203+
MediaPath = $TestDrive
191204
FileStreamLevel = $MockFileStreamLevel
192205
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
193206
}
@@ -201,6 +214,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
201214
} -ScriptBlock {
202215
{
203216
Assert-SetupActionProperties -Property @{
217+
MediaPath = $TestDrive
204218
FileStreamLevel = $MockFileStreamLevel
205219
} -SetupAction 'NotUsed'
206220
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -238,6 +252,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
238252
InModuleScope -Parameters $_ -ScriptBlock {
239253
{
240254
Assert-SetupActionProperties -Property @{
255+
MediaPath = $TestDrive
241256
$MockParameterName = 'AccountName'
242257
} -SetupAction 'NotUsed'
243258
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -274,7 +289,8 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
274289
It 'Should not throw an exception' {
275290
InModuleScope -Parameters $_ -ScriptBlock {
276291
$null = Assert-SetupActionProperties -Property @{
277-
$MockParameterName = 'AccountName'
292+
MediaPath = $TestDrive
293+
$MockParameterName = 'AccountName'
278294
($MockParameterName -replace 'Account', 'Password') = 'Password'
279295
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
280296
}
@@ -316,6 +332,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
316332
It 'Should not throw an exception' {
317333
InModuleScope -Parameters $_ -ScriptBlock {
318334
$null = Assert-SetupActionProperties -Property @{
335+
MediaPath = $TestDrive
319336
$MockParameterName = 'myMSA$'
320337
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
321338
}
@@ -553,6 +570,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
553570
InModuleScope -Parameters $_ -ScriptBlock {
554571
{
555572
Assert-SetupActionProperties -Property @{
573+
MediaPath = $TestDrive
556574
ASServerMode = 'PowerPivot'
557575
} -SetupAction $MockSetupAction
558576
} | Should -Throw -ErrorId 'ASAP0001,Assert-SetupActionProperties' # cSpell: disable-line
@@ -569,10 +587,51 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
569587
InModuleScope -Parameters $_ -ScriptBlock {
570588
{
571589
Assert-SetupActionProperties -Property @{
590+
MediaPath = $TestDrive
572591
RsInstallMode = 'DefaultNativeMode'
573592
} -SetupAction $MockSetupAction
574593
} | Should -Throw -ErrorId 'ASAP0002,Assert-SetupActionProperties' # cSpell: disable-line
575594
}
576595
}
577596
}
597+
598+
Context 'When specifying AllowDqRemoval with SQL Server version older than 2025 (17.x)' {
599+
BeforeAll {
600+
Mock -CommandName Get-FileVersion -MockWith {
601+
return [PSCustomObject] @{
602+
ProductVersion = '16.0.1000.6'
603+
}
604+
}
605+
}
606+
607+
It 'Should throw an exception' {
608+
InModuleScope -ScriptBlock {
609+
{
610+
Assert-SetupActionProperties -Property @{
611+
MediaPath = $TestDrive
612+
AllowDqRemoval = $true
613+
} -SetupAction 'Upgrade'
614+
} | Should -Throw -ErrorId 'ASAP0003,Assert-SetupActionProperties' # cSpell: disable-line
615+
}
616+
}
617+
}
618+
619+
Context 'When specifying AllowDqRemoval with SQL Server 2025 (17.x)' {
620+
BeforeAll {
621+
Mock -CommandName Get-FileVersion -MockWith {
622+
return [PSCustomObject] @{
623+
ProductVersion = '17.0.1000.6'
624+
}
625+
}
626+
}
627+
628+
It 'Should not throw an exception' {
629+
InModuleScope -ScriptBlock {
630+
$null = Assert-SetupActionProperties -Property @{
631+
MediaPath = $TestDrive
632+
AllowDqRemoval = $true
633+
} -SetupAction 'Upgrade' -ErrorAction 'Stop'
634+
}
635+
}
636+
}
578637
}

tests/Unit/Private/Invoke-SetupAction.Tests.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
8787
@{
8888
MockParameterSetName = 'Upgrade'
8989
# cSpell: disable-next
90-
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>]'
90+
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>]'
9191
}
9292
@{
9393
MockParameterSetName = 'EditionUpgrade'
@@ -983,6 +983,11 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
983983
MockParameterValue = $true
984984
MockExpectedRegEx = '\/ALLOWUPGRADEFORSSRSSHAREPOINTMODE=True' # cspell: disable-line
985985
}
986+
@{
987+
MockParameterName = 'AllowDqRemoval'
988+
MockParameterValue = $true
989+
MockExpectedRegEx = '\/IACCEPTDQUNINSTALL\s*' # cspell: disable-line
990+
}
986991
@{
987992
MockParameterName = 'FailoverClusterRollOwnership'
988993
MockParameterValue = 2

tests/Unit/Public/Install-SqlDscServer.Tests.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
7777
@{
7878
MockParameterSetName = 'Upgrade'
7979
# cSpell: disable-next
80-
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>]'
80+
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>]'
8181
}
8282
@{
8383
MockParameterSetName = 'EditionUpgrade'
@@ -785,6 +785,11 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
785785
MockParameterValue = 2
786786
MockExpectedRegEx = '\/FAILOVERCLUSTERROLLOWNERSHIP=2' # cspell: disable-line
787787
}
788+
@{
789+
MockParameterName = 'AllowDqRemoval'
790+
MockParameterValue = $true
791+
MockExpectedRegEx = '\/IACCEPTDQUNINSTALL\s*' # cspell: disable-line
792+
}
788793
) {
789794
BeforeAll {
790795
Mock -CommandName Start-SqlSetupProcess -MockWith {

0 commit comments

Comments
 (0)