Skip to content

Commit

Permalink
Install-SqlDscServer: Fix bug for PrepareImage (#1961)
Browse files Browse the repository at this point in the history
- `Install-SqlDscServer`
  - Now the parameter `InstanceName` can no longer be specified (as per
    the SQL Server documentation) for the setup action `PrepareImage`
    (issue #1960).
  • Loading branch information
johlju authored Aug 20, 2023
1 parent 22c4f2d commit f3df24b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix duplication of SQL Server Browser Firewall Rule when deploying
Analysis Services feature ([issue #1942](https://github.com/dsccommunity/SqlServerDsc/issues/1942)).
- SqlLogin
- Attempting to disable and already disabled login throws an error ([issue #1952](https://github.com/dsccommunity/SqlServerDsc/issues/1952))
- Attempting to disable and already disabled login throws an error ([issue #1952](https://github.com/dsccommunity/SqlServerDsc/issues/1952)).
- `Install-SqlDscServer`
- Now the parameter `InstanceName` can no longer be specified (as per
the SQL Server documentation) for the setup action `PrepareImage`
([issue #1960](https://github.com/dsccommunity/SqlServerDsc/issues/1960)).

## [16.3.1] - 2023-05-06

Expand Down
3 changes: 1 addition & 2 deletions source/Private/Invoke-SetupAction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
Uninstalls the database engine from the named instance MyInstance.
.EXAMPLE
Invoke-SetupAction -PrepareImage -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE' -InstanceId 'MyInstance' -MediaPath 'E:\'
Invoke-SetupAction -PrepareImage -AcceptLicensingTerms -Features 'SQLENGINE' -InstanceId 'MyInstance' -MediaPath 'E:\'
Prepares the server for using the database engine for an instance named 'MyInstance'.
Expand Down Expand Up @@ -577,7 +577,6 @@ function Invoke-SetupAction

[Parameter(ParameterSetName = 'Install', Mandatory = $true)]
[Parameter(ParameterSetName = 'Uninstall', Mandatory = $true)]
[Parameter(ParameterSetName = 'PrepareImage', Mandatory = $true)]
[Parameter(ParameterSetName = 'Upgrade', Mandatory = $true)]
[Parameter(ParameterSetName = 'EditionUpgrade', Mandatory = $true)]
[Parameter(ParameterSetName = 'Repair', Mandatory = $true)]
Expand Down
3 changes: 1 addition & 2 deletions source/Public/Install-SqlDscServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
Installs SQL Server using the configuration file 'MySqlConfig.ini'.
.EXAMPLE
Install-SqlDscServer -PrepareImage -AcceptLicensingTerms -InstanceName 'MyInstance' -Features 'SQLENGINE' -InstanceId 'MyInstance' -MediaPath 'E:\'
Install-SqlDscServer -PrepareImage -AcceptLicensingTerms -Features 'SQLENGINE' -InstanceId 'MyInstance' -MediaPath 'E:\'
Prepares the server for using the database engine for an instance named 'MyInstance'.
Expand Down Expand Up @@ -471,7 +471,6 @@ function Install-SqlDscServer
$MediaPath,

[Parameter(ParameterSetName = 'Install', Mandatory = $true)]
[Parameter(ParameterSetName = 'PrepareImage', Mandatory = $true)]
[Parameter(ParameterSetName = 'Upgrade', Mandatory = $true)]
[Parameter(ParameterSetName = 'EditionUpgrade', Mandatory = $true)]
[Parameter(ParameterSetName = 'InstallFailoverCluster', Mandatory = $true)]
Expand Down
6 changes: 1 addition & 5 deletions tests/Unit/Private/Invoke-SetupAction.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
@{
MockParameterSetName = 'PrepareImage'
# cSpell: disable-next
MockExpectedParameters = '-PrepareImage -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> -Features <string[]> -InstanceId <string> [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstanceDir <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
MockExpectedParameters = '-PrepareImage -AcceptLicensingTerms -MediaPath <string> -Features <string[]> -InstanceId <string> [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstanceDir <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
}
@{
MockParameterSetName = 'CompleteImage'
Expand Down Expand Up @@ -3188,7 +3188,6 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
PrepareImage = $true
AcceptLicensingTerms = $true
MediaPath = '\SqlMedia'
InstanceName = 'INSTANCE'
# Intentionally using both upper- and lower-case.
Features = 'SqlEngine'
InstanceId = 'Instance'
Expand All @@ -3205,7 +3204,6 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
$ArgumentList | Should -MatchExactly '\/ACTION=PrepareImage'
$ArgumentList | Should -MatchExactly '\/IACCEPTSQLSERVERLICENSETERMS' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE'
$ArgumentList | Should -MatchExactly '\/INSTANCENAME="INSTANCE"' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/INSTANCEID="Instance"' # cspell: disable-line

# Return $true if none of the above throw.
Expand All @@ -3224,7 +3222,6 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
$ArgumentList | Should -MatchExactly '\/ACTION=PrepareImage'
$ArgumentList | Should -MatchExactly '\/IACCEPTSQLSERVERLICENSETERMS' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE'
$ArgumentList | Should -MatchExactly '\/INSTANCENAME="INSTANCE"' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/INSTANCEID="Instance"' # cspell: disable-line

# Return $true if none of the above throw.
Expand Down Expand Up @@ -3307,7 +3304,6 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
PrepareImage = $true
AcceptLicensingTerms = $true
MediaPath = '\SqlMedia'
InstanceName = 'INSTANCE'
# Intentionally using both upper- and lower-case.
Features = 'SqlEngine'
InstanceId = 'Instance'
Expand Down
6 changes: 1 addition & 5 deletions tests/Unit/Public/Install-SqlDscServer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
@{
MockParameterSetName = 'PrepareImage'
# cSpell: disable-next
MockExpectedParameters = '-PrepareImage -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> -Features <string[]> -InstanceId <string> [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstanceDir <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
MockExpectedParameters = '-PrepareImage -AcceptLicensingTerms -MediaPath <string> -Features <string[]> -InstanceId <string> [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstanceDir <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
}
@{
MockParameterSetName = 'Upgrade'
Expand Down Expand Up @@ -2035,7 +2035,6 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
PrepareImage = $true
AcceptLicensingTerms = $true
MediaPath = '\SqlMedia'
InstanceName = 'INSTANCE'
# Intentionally using both upper- and lower-case.
Features = 'SqlEngine'
InstanceId = 'Instance'
Expand All @@ -2050,7 +2049,6 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
$ArgumentList | Should -MatchExactly '\/ACTION=PrepareImage'
$ArgumentList | Should -MatchExactly '\/IACCEPTSQLSERVERLICENSETERMS' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE'
$ArgumentList | Should -MatchExactly '\/INSTANCENAME="INSTANCE"' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/INSTANCEID="Instance"' # cspell: disable-line

# Return $true if none of the above throw.
Expand All @@ -2067,7 +2065,6 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
$ArgumentList | Should -MatchExactly '\/ACTION=PrepareImage'
$ArgumentList | Should -MatchExactly '\/IACCEPTSQLSERVERLICENSETERMS' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/FEATURES=SQLENGINE'
$ArgumentList | Should -MatchExactly '\/INSTANCENAME="INSTANCE"' # cspell: disable-line
$ArgumentList | Should -MatchExactly '\/INSTANCEID="Instance"' # cspell: disable-line

# Return $true if none of the above throw.
Expand Down Expand Up @@ -2146,7 +2143,6 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
PrepareImage = $true
AcceptLicensingTerms = $true
MediaPath = '\SqlMedia'
InstanceName = 'INSTANCE'
# Intentionally using both upper- and lower-case.
Features = 'SqlEngine'
InstanceId = 'Instance'
Expand Down

0 comments on commit f3df24b

Please sign in to comment.