Skip to content

Commit 34e016d

Browse files
committed
Invoke-SetupAction: Updates for SQL Server 2025
1 parent fdc54b9 commit 34e016d

File tree

6 files changed

+105
-10
lines changed

6 files changed

+105
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5959
- Added parameter `-KillActiveSessions` to automatically terminate any active
6060
sessions for a login before dropping it
6161
([issue #2372](https://github.com/dsccommunity/SqlServerDsc/issues/2372)).
62+
- `Invoke-SetupAction`
63+
- Added parameter `AllowDqRemoval` for the `Upgrade` action to allow removal
64+
of Data Quality (DQ) Services during upgrade to SQL Server 2025 (17.x) and
65+
later versions.
66+
- Now outputs setup progress when `-Verbose` is passed by using `/QUIETSIMPLE`
67+
instead of `/QUIET`.
6268

6369
### Changed
6470

source/Private/Assert-SetupActionProperties.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,26 @@ function Assert-SetupActionProperties
238238
)
239239
}
240240
}
241+
242+
# The parameter AllowDqRemoval is only allowed for SQL Server 2025 (17.x) and later versions.
243+
if ($Property.ContainsKey('AllowDqRemoval'))
244+
{
245+
$setupExecutableFileVersion = $Property.MediaPath |
246+
Join-Path -ChildPath 'setup.exe' |
247+
Get-FileVersion
248+
249+
$majorVersion = $setupExecutableFileVersion.ProductVersion.Split('.')[0]
250+
251+
if ([System.Int32] $majorVersion -lt 17)
252+
{
253+
$PSCmdlet.ThrowTerminatingError(
254+
[System.Management.Automation.ErrorRecord]::new(
255+
($script:localizedData.InstallSqlServerProperties_AllowDqRemovalInvalidVersion -f $majorVersion),
256+
'ASAP0003', # cSpell: disable-line
257+
[System.Management.Automation.ErrorCategory]::InvalidOperation,
258+
'Command parameters'
259+
)
260+
)
261+
}
262+
}
241263
}

source/Private/Invoke-SetupAction.ps1

Lines changed: 28 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,16 @@ function Invoke-SetupAction
14281436

14291437
$ErrorActionPreference = $originalErrorActionPreference
14301438

1431-
$setupArgument = '/QUIET /ACTION={0}' -f $setupAction
1439+
if ($VerbosePreference -eq 'Continue')
1440+
{
1441+
$quietMode = '/QUIETSIMPLE'
1442+
}
1443+
else
1444+
{
1445+
$quietMode = '/QUIET'
1446+
}
1447+
1448+
$setupArgument = '{0} /ACTION={1}' -f $quietMode, $setupAction
14321449

14331450
if ($DebugPreference -in @('Continue', 'Inquire'))
14341451
{
@@ -1534,23 +1551,25 @@ function Invoke-SetupAction
15341551
# Must be handled differently because the parameter name could not be $PID.
15351552
'PRODUCTKEY' # cspell: disable-line
15361553
{
1537-
# Remove the argument that was added above.
1538-
$setupArgument = $setupArgument -replace ' \/{0}' -f $parameterName
1539-
15401554
$sensitiveValue += $PSBoundParameters.$parameterName
15411555

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

15441558
break
15451559
}
15461560

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

1553-
$setupArgument += ' /SQL_INST_JAVA'
1566+
break
1567+
}
1568+
1569+
# Must be handled differently because parameter name does not match the argument name.
1570+
'ALLOWDQREMOVAL' # cspell: disable-line
1571+
{
1572+
$setupArgument = $setupArgument -replace $parameterName, 'IACKNOWLEDGEDQUNINSTALL' # cspell: disable-line
15541573

15551574
break
15561575
}

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.
165166
166167
## Get-SqlDscManagedComputer
167168
ManagedComputer_GetState = Returning the managed computer object for server {0}.

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,4 +575,46 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
575575
}
576576
}
577577
}
578+
579+
Context 'When specifying AllowDqRemoval with SQL Server version older than 2025 (17.x)' {
580+
BeforeAll {
581+
Mock -CommandName Get-FileVersion -MockWith {
582+
return [PSCustomObject] @{
583+
ProductVersion = '16.0.1000.6'
584+
}
585+
}
586+
}
587+
588+
It 'Should throw an exception' {
589+
InModuleScope -ScriptBlock {
590+
{
591+
Assert-SetupActionProperties -Property @{
592+
MediaPath = $TestDrive
593+
AllowDqRemoval = $true
594+
} -SetupAction 'Upgrade'
595+
} | Should -Throw -ErrorId 'ASAP0003,Assert-SetupActionProperties' # cSpell: disable-line
596+
}
597+
}
598+
}
599+
600+
Context 'When specifying AllowDqRemoval with SQL Server 2025 (17.x)' {
601+
BeforeAll {
602+
Mock -CommandName Get-FileVersion -MockWith {
603+
return [PSCustomObject] @{
604+
ProductVersion = '17.0.1000.6'
605+
}
606+
}
607+
}
608+
609+
It 'Should not throw an exception' {
610+
InModuleScope -ScriptBlock {
611+
{
612+
Assert-SetupActionProperties -Property @{
613+
MediaPath = $TestDrive
614+
AllowDqRemoval = $true
615+
} -SetupAction 'Upgrade'
616+
} | Should -Not -Throw
617+
}
618+
}
619+
}
578620
}

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 = '\/IACKNOWLEDGEDQUNINSTALL\s*' # cspell: disable-line
990+
}
986991
@{
987992
MockParameterName = 'FailoverClusterRollOwnership'
988993
MockParameterValue = 2

0 commit comments

Comments
 (0)