Skip to content

Commit

Permalink
Install-SqlDscServer: Fix ASSysAdminAccounts and `SqlSysAdminAcco…
Browse files Browse the repository at this point in the history
…unts` (#1863)

- `Assert-SetupActionProperties`
  - Now throws an exception if the setup action is `Install` and the feature
    analysis services is specified without the parameter `ASSysAdminAccounts`
    (issue #1845).
  - Now throws an exception if the setup action is `Install` and the feature
    database engine is specified without the parameter `SqlSysAdminAccounts`.
- `Invoke-SetupAction`
  - The parameter `SqlSysAdminAccounts` is no longer mandatory to allow
    installation where the database engine is not installed.
- `Install-SqlDscServer`
  - The parameter `SqlSysAdminAccounts` is no longer mandatory to allow
    installation where the database engine is not installed.
  • Loading branch information
johlju authored Mar 4, 2023
1 parent 58b765c commit e65a410
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The private function `Import-SQLPSModule` was replaced throughout with
the public command `Import-SqlDscPreferredModule` ([issue #1848](https://github.com/dsccommunity/SqlServerDsc/issues/1848)).

### Fixed

- `Assert-SetupActionProperties`
- Now throws an exception if the setup action is `Install` and the feature
analysis services is specified without the parameter `ASSysAdminAccounts`
([issue #1845](https://github.com/dsccommunity/SqlServerDsc/issues/1845)).
- Now throws an exception if the setup action is `Install` and the feature
database engine is specified without the parameter `SqlSysAdminAccounts`.
- `Invoke-SetupAction`
- The parameter `SqlSysAdminAccounts` is no longer mandatory to allow
installation where the database engine is not installed.
- `Install-SqlDscServer`
- The parameter `SqlSysAdminAccounts` is no longer mandatory to allow
installation where the database engine is not installed.

## [16.1.0] - 2023-02-28

### Removed
Expand Down
17 changes: 17 additions & 0 deletions source/Private/Assert-SetupActionProperties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,21 @@ function Assert-SetupActionProperties
)
}
}

if ($SetupAction -in ('Install'))
{
if ($Property.ContainsKey('Features') -and $Property.Features -contains 'SQLENGINE')
{
Assert-BoundParameter -BoundParameterList $Property -RequiredParameter @(
'SqlSysAdminAccounts'
)
}

if ($Property.ContainsKey('Features') -and $Property.Features -contains 'AS')
{
Assert-BoundParameter -BoundParameterList $Property -RequiredParameter @(
'ASSysAdminAccounts'
)
}
}
}
2 changes: 1 addition & 1 deletion source/Private/Invoke-SetupAction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ function Invoke-SetupAction
[System.String]
$SqlSvcStartupType,

[Parameter(ParameterSetName = 'Install', Mandatory = $true)]
[Parameter(ParameterSetName = 'Install')]
[Parameter(ParameterSetName = 'CompleteImage')]
[Parameter(ParameterSetName = 'RebuildDatabase', Mandatory = $true)]
[Parameter(ParameterSetName = 'InstallFailoverCluster', Mandatory = $true)]
Expand Down
2 changes: 1 addition & 1 deletion source/Public/Install-SqlDscServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ function Install-SqlDscServer
[System.String]
$SqlSvcStartupType,

[Parameter(ParameterSetName = 'Install', Mandatory = $true)]
[Parameter(ParameterSetName = 'Install')]
[Parameter(ParameterSetName = 'InstallFailoverCluster', Mandatory = $true)]
[Parameter(ParameterSetName = 'InstallRole')]
[System.String[]]
Expand Down
16 changes: 13 additions & 3 deletions tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,18 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
MockMissingParameterName = 'RSSvcAccount'
MockFeature = 'RS'
}
@{
MockSetupAction = 'Install'
MockFeature = 'AS'
MockMissingParameterName = 'ASSysAdminAccounts'
}
@{
MockSetupAction = 'Install'
MockFeature = 'SQLENGINE'
MockMissingParameterName = 'SqlSysAdminAccounts'
}
) {
It 'Should not throw an exception' {
It 'Should throw an exception' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
Expand All @@ -508,7 +518,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
MockSetupAction = 'CompleteFailoverCluster'
}
) {
It 'Should not throw an exception' {
It 'Should throw an exception' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
Expand All @@ -524,7 +534,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
MockSetupAction = 'AddNode'
}
) {
It 'Should not throw an exception' {
It 'Should throw an exception' {
InModuleScope -Parameters $_ -ScriptBlock {
{
Assert-SetupActionProperties -Property @{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Private/Invoke-SetupAction.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Describe 'Invoke-SetupAction' -Tag 'Private' {
@{
MockParameterSetName = 'Install'
# cSpell: disable-next
MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> -Features <string[]> -SqlSysAdminAccounts <string[]> [-SuppressPrivacyStatementNotice] [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstallSharedWowDir <string>] [-InstanceDir <string>] [-InstanceId <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBDMSSvcAccount <string>] [-PBDMSSvcPassword <securestring>] [-PBDMSSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-ProductKey <string>] [-AgtSvcAccount <string>] [-AgtSvcPassword <securestring>] [-AgtSvcStartupType <string>] [-ASBackupDir <string>] [-ASCollation <string>] [-ASConfigDir <string>] [-ASDataDir <string>] [-ASLogDir <string>] [-ASTempDir <string>] [-ASServerMode <string>] [-ASSvcAccount <string>] [-ASSvcPassword <securestring>] [-ASSvcStartupType <string>] [-ASSysAdminAccounts <string[]>] [-ASProviderMSOLAP] [-BrowserSvcStartupType <string>] [-EnableRanU] [-InstallSqlDataDir <string>] [-SqlBackupDir <string>] [-SecurityMode <string>] [-SAPwd <securestring>] [-SqlCollation <string>] [-SqlSvcAccount <string>] [-SqlSvcPassword <securestring>] [-SqlSvcStartupType <string>] [-SqlTempDbDir <string>] [-SqlTempDbLogDir <string>] [-SqlTempDbFileCount <ushort>] [-SqlTempDbFileSize <ushort>] [-SqlTempDbFileGrowth <ushort>] [-SqlTempDbLogFileSize <ushort>] [-SqlTempDbLogFileGrowth <ushort>] [-SqlUserDbDir <string>] [-SqlSvcInstantFileInit] [-SqlUserDbLogDir <string>] [-SqlMaxDop <ushort>] [-UseSqlRecommendedMemoryLimits] [-SqlMinMemory <uint>] [-SqlMaxMemory <uint>] [-FileStreamLevel <ushort>] [-FileStreamShareName <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-NpEnabled] [-TcpEnabled] [-RsInstallMode <string>] [-RSSvcAccount <string>] [-RSSvcPassword <securestring>] [-RSSvcStartupType <string>] [-MPYCacheDirectory <string>] [-MRCacheDirectory <string>] [-SqlInstJava] [-SqlJavaDir <string>] [-AzureSubscriptionId <string>] [-AzureResourceGroup <string>] [-AzureRegion <string>] [-AzureTenantId <string>] [-AzureServicePrincipal <string>] [-AzureServicePrincipalSecret <securestring>] [-AzureArcProxy <string>] [-SkipRules <string[]>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> -Features <string[]> [-SuppressPrivacyStatementNotice] [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstallSharedWowDir <string>] [-InstanceDir <string>] [-InstanceId <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBDMSSvcAccount <string>] [-PBDMSSvcPassword <securestring>] [-PBDMSSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-ProductKey <string>] [-AgtSvcAccount <string>] [-AgtSvcPassword <securestring>] [-AgtSvcStartupType <string>] [-ASBackupDir <string>] [-ASCollation <string>] [-ASConfigDir <string>] [-ASDataDir <string>] [-ASLogDir <string>] [-ASTempDir <string>] [-ASServerMode <string>] [-ASSvcAccount <string>] [-ASSvcPassword <securestring>] [-ASSvcStartupType <string>] [-ASSysAdminAccounts <string[]>] [-ASProviderMSOLAP] [-BrowserSvcStartupType <string>] [-EnableRanU] [-InstallSqlDataDir <string>] [-SqlBackupDir <string>] [-SecurityMode <string>] [-SAPwd <securestring>] [-SqlCollation <string>] [-SqlSvcAccount <string>] [-SqlSvcPassword <securestring>] [-SqlSvcStartupType <string>] [-SqlSysAdminAccounts <string[]>] [-SqlTempDbDir <string>] [-SqlTempDbLogDir <string>] [-SqlTempDbFileCount <ushort>] [-SqlTempDbFileSize <ushort>] [-SqlTempDbFileGrowth <ushort>] [-SqlTempDbLogFileSize <ushort>] [-SqlTempDbLogFileGrowth <ushort>] [-SqlUserDbDir <string>] [-SqlSvcInstantFileInit] [-SqlUserDbLogDir <string>] [-SqlMaxDop <ushort>] [-UseSqlRecommendedMemoryLimits] [-SqlMinMemory <uint>] [-SqlMaxMemory <uint>] [-FileStreamLevel <ushort>] [-FileStreamShareName <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-NpEnabled] [-TcpEnabled] [-RsInstallMode <string>] [-RSSvcAccount <string>] [-RSSvcPassword <securestring>] [-RSSvcStartupType <string>] [-MPYCacheDirectory <string>] [-MRCacheDirectory <string>] [-SqlInstJava] [-SqlJavaDir <string>] [-AzureSubscriptionId <string>] [-AzureResourceGroup <string>] [-AzureRegion <string>] [-AzureTenantId <string>] [-AzureServicePrincipal <string>] [-AzureServicePrincipalSecret <securestring>] [-AzureArcProxy <string>] [-SkipRules <string[]>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
}
@{
MockParameterSetName = 'InstallRole'
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Public/Install-SqlDscServer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Describe 'Install-SqlDscServer' -Tag 'Public' {
@{
MockParameterSetName = 'Install'
# cSpell: disable-next
MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> -Features <string[]> -SqlSysAdminAccounts <string[]> [-SuppressPrivacyStatementNotice] [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstallSharedWowDir <string>] [-InstanceDir <string>] [-InstanceId <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBDMSSvcAccount <string>] [-PBDMSSvcPassword <securestring>] [-PBDMSSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-ProductKey <string>] [-AgtSvcAccount <string>] [-AgtSvcPassword <securestring>] [-AgtSvcStartupType <string>] [-ASBackupDir <string>] [-ASCollation <string>] [-ASConfigDir <string>] [-ASDataDir <string>] [-ASLogDir <string>] [-ASTempDir <string>] [-ASServerMode <string>] [-ASSvcAccount <string>] [-ASSvcPassword <securestring>] [-ASSvcStartupType <string>] [-ASSysAdminAccounts <string[]>] [-ASProviderMSOLAP] [-BrowserSvcStartupType <string>] [-EnableRanU] [-InstallSqlDataDir <string>] [-SqlBackupDir <string>] [-SecurityMode <string>] [-SAPwd <securestring>] [-SqlCollation <string>] [-SqlSvcAccount <string>] [-SqlSvcPassword <securestring>] [-SqlSvcStartupType <string>] [-SqlTempDbDir <string>] [-SqlTempDbLogDir <string>] [-SqlTempDbFileCount <ushort>] [-SqlTempDbFileSize <ushort>] [-SqlTempDbFileGrowth <ushort>] [-SqlTempDbLogFileSize <ushort>] [-SqlTempDbLogFileGrowth <ushort>] [-SqlUserDbDir <string>] [-SqlSvcInstantFileInit] [-SqlUserDbLogDir <string>] [-SqlMaxDop <ushort>] [-UseSqlRecommendedMemoryLimits] [-SqlMinMemory <uint>] [-SqlMaxMemory <uint>] [-FileStreamLevel <ushort>] [-FileStreamShareName <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-NpEnabled] [-TcpEnabled] [-RsInstallMode <string>] [-RSSvcAccount <string>] [-RSSvcPassword <securestring>] [-RSSvcStartupType <string>] [-MPYCacheDirectory <string>] [-MRCacheDirectory <string>] [-SqlInstJava] [-SqlJavaDir <string>] [-AzureSubscriptionId <string>] [-AzureResourceGroup <string>] [-AzureRegion <string>] [-AzureTenantId <string>] [-AzureServicePrincipal <string>] [-AzureServicePrincipalSecret <securestring>] [-AzureArcProxy <string>] [-SkipRules <string[]>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
MockExpectedParameters = '-Install -AcceptLicensingTerms -MediaPath <string> -InstanceName <string> -Features <string[]> [-SuppressPrivacyStatementNotice] [-IAcknowledgeEntCalLimits] [-Enu] [-UpdateEnabled] [-UpdateSource <string>] [-InstallSharedDir <string>] [-InstallSharedWowDir <string>] [-InstanceDir <string>] [-InstanceId <string>] [-PBEngSvcAccount <string>] [-PBEngSvcPassword <securestring>] [-PBEngSvcStartupType <string>] [-PBDMSSvcAccount <string>] [-PBDMSSvcPassword <securestring>] [-PBDMSSvcStartupType <string>] [-PBStartPortRange <ushort>] [-PBEndPortRange <ushort>] [-PBScaleOut] [-ProductKey <string>] [-AgtSvcAccount <string>] [-AgtSvcPassword <securestring>] [-AgtSvcStartupType <string>] [-ASBackupDir <string>] [-ASCollation <string>] [-ASConfigDir <string>] [-ASDataDir <string>] [-ASLogDir <string>] [-ASTempDir <string>] [-ASServerMode <string>] [-ASSvcAccount <string>] [-ASSvcPassword <securestring>] [-ASSvcStartupType <string>] [-ASSysAdminAccounts <string[]>] [-ASProviderMSOLAP] [-BrowserSvcStartupType <string>] [-EnableRanU] [-InstallSqlDataDir <string>] [-SqlBackupDir <string>] [-SecurityMode <string>] [-SAPwd <securestring>] [-SqlCollation <string>] [-SqlSvcAccount <string>] [-SqlSvcPassword <securestring>] [-SqlSvcStartupType <string>] [-SqlSysAdminAccounts <string[]>] [-SqlTempDbDir <string>] [-SqlTempDbLogDir <string>] [-SqlTempDbFileCount <ushort>] [-SqlTempDbFileSize <ushort>] [-SqlTempDbFileGrowth <ushort>] [-SqlTempDbLogFileSize <ushort>] [-SqlTempDbLogFileGrowth <ushort>] [-SqlUserDbDir <string>] [-SqlSvcInstantFileInit] [-SqlUserDbLogDir <string>] [-SqlMaxDop <ushort>] [-UseSqlRecommendedMemoryLimits] [-SqlMinMemory <uint>] [-SqlMaxMemory <uint>] [-FileStreamLevel <ushort>] [-FileStreamShareName <string>] [-ISSvcAccount <string>] [-ISSvcPassword <securestring>] [-ISSvcStartupType <string>] [-NpEnabled] [-TcpEnabled] [-RsInstallMode <string>] [-RSSvcAccount <string>] [-RSSvcPassword <securestring>] [-RSSvcStartupType <string>] [-MPYCacheDirectory <string>] [-MRCacheDirectory <string>] [-SqlInstJava] [-SqlJavaDir <string>] [-AzureSubscriptionId <string>] [-AzureResourceGroup <string>] [-AzureRegion <string>] [-AzureTenantId <string>] [-AzureServicePrincipal <string>] [-AzureServicePrincipalSecret <securestring>] [-AzureArcProxy <string>] [-SkipRules <string[]>] [-ProductCoveredBySA] [-Timeout <uint>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]'
}
@{
MockParameterSetName = 'InstallRole'
Expand Down

0 comments on commit e65a410

Please sign in to comment.