Skip to content

Commit

Permalink
Added New parameter ProductCoveredbySA that is introduced in SQL 2022 (
Browse files Browse the repository at this point in the history
…#2044)

- SqlSetup
  - Added new parameter ProductCoveredbySA which is introduced in SQL 2022.
  • Loading branch information
sara921-spec authored Sep 29, 2024
1 parent 3c30929 commit dd56306
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- SqlSetup
- Added new parameter ProductCoveredbySA which is introduced in SQL 2022.

### Added

- `Connect-SqlDscDatabaseEngine`
- Added integration test for the command.
- `Uninstall-SqlDscServer`
Expand Down
37 changes: 37 additions & 0 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ function Get-TargetResource
UseEnglish = $UseEnglish
ServerName = $ServerName
SqlVersion = $null
ProductCoveredBySA = $null
}

<#
Expand Down Expand Up @@ -318,6 +319,16 @@ function Get-TargetResource
$getTargetResourceReturnValue.SqlTempdbLogFileGrowth = $currentTempDbProperties.SqlTempdbLogFileGrowth
}

if ($sqlVersion -ge 16)
{
# Grab the value of ProductCoveredBySA from the registry based on the instance
$getRegistryPropertyParams = @{
Path = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL$($SqlVersion).$($InstanceName)\Setup"
Name = 'IsProductCoveredBySA'
}
$getTargetResourceReturnValue.ProductCoveredBySA = Get-RegistryPropertyValue @getRegistryPropertyParams
}

# Get all members of the sysadmin role.
$sqlSystemAdminAccounts = Get-SqlRoleMembers -RoleName 'sysadmin' -ServerName $sqlHostName -InstanceName $InstanceName
$getTargetResourceReturnValue.SQLSysAdminAccounts = $sqlSystemAdminAccounts
Expand Down Expand Up @@ -518,6 +529,11 @@ function Get-TargetResource
.PARAMETER ProductKey
Product key for licensed installations.
.PARAMETER ProductCoveredBySA
Specifies the license coverage for SQL Server. True indicates it's covered under Software Assurance or SQL Server subscription.
False, or omitting the parameter, indicates it's covered under a SQL Server license.
Default value is False.
.PARAMETER UpdateEnabled
Enabled updates during installation.
Expand Down Expand Up @@ -748,6 +764,10 @@ function Set-TargetResource
[System.String]
$ProductKey,

[Parameter()]
[System.Boolean]
$ProductCoveredBySA,

[Parameter()]
[System.String]
$UpdateEnabled,
Expand Down Expand Up @@ -1290,6 +1310,12 @@ function Set-TargetResource
$setupArguments['FailoverClusterIPAddresses'] = $clusterIPAddresses
}

# Add Parameter ProductCoveredBySA
if ($PSBoundParameters.ContainsKey('ProductCoveredBySA'))
{
$setupArguments['ProductCoveredBySA'] = $ProductCoveredBySA
}

# Add standard install arguments
$setupArguments += @{
Quiet = $true
Expand Down Expand Up @@ -1767,6 +1793,13 @@ function Set-TargetResource
.PARAMETER ProductKey
Product key for licensed installations.
.PARAMETER ProductCoveredBySA
Specifies the license coverage for SQL Server. True indicates it's covered under Software Assurance or SQL Server subscription.
False, or omitting the parameter, indicates it's covered under a SQL Server license.
Default value is False.
Not used in Test-TargetResource.
.PARAMETER UpdateEnabled
Enabled updates during installation.
Expand Down Expand Up @@ -2005,6 +2038,10 @@ function Test-TargetResource
[System.String]
$ProductKey,

[Parameter()]
[System.Boolean]
$ProductCoveredBySA,

[Parameter()]
[System.String]
$UpdateEnabled,
Expand Down
1 change: 1 addition & 0 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class DSC_SqlSetup : OMI_BaseResource
[Key, Description("Specifies the name of the instance to be installed.")] String InstanceName;
[Write, Description("_SQL Server_ instance ID (if different from parameter **InstanceName**).")] String InstanceID;
[Write, Description("Product key for licensed installations.")] String ProductKey;
[Write, Description("Specifies the Software Assurance license coverage for SQL Server instance.")] Boolean ProductCoveredbySA;
[Write, Description("Enabled updates during installation.")] String UpdateEnabled;
[Write, Description("Path to the source of updates to be applied during installation.")] String UpdateSource;
[Write, Description("Enable customer experience reporting.")] String SQMReporting;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<#
.DESCRIPTION
This example shows how to install a default instance of SQL Server, and
Analysis Services in Tabular mode, on a single server.
It contains configurations that apply to Sql Server 2022 or later only.
.NOTES
SQL Server setup is run using the SYSTEM account. Even if SetupCredential is provided
it is not used to install SQL Server at this time (see issue #139).
#>

Configuration Example
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$SqlInstallCredential,

[Parameter()]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential = $SqlInstallCredential,

[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$SqlServiceCredential,

[Parameter()]
[ValidateNotNullOrEmpty()]
[System.Management.Automation.PSCredential]
$SqlAgentServiceCredential = $SqlServiceCredential
)

Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0'
Import-DscResource -ModuleName 'SqlServerDsc'

node localhost
{
#region Install prerequisites for SQL Server
WindowsFeature 'NetFramework35'
{
Name = 'NET-Framework-Core'
Source = '\\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path.
Ensure = 'Present'
}

WindowsFeature 'NetFramework45'
{
Name = 'NET-Framework-45-Core'
Ensure = 'Present'
}
#endregion Install prerequisites for SQL Server

#region Install SQL Server
SqlSetup 'InstallDefaultInstance'
{
InstanceName = 'MSSQLSERVER'
Features = 'SQLENGINE,AS'
SQLCollation = 'SQL_Latin1_General_CP1_CI_AS'
SQLSvcAccount = $SqlServiceCredential
AgtSvcAccount = $SqlAgentServiceCredential
ASSvcAccount = $SqlServiceCredential
SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
InstallSharedDir = 'C:\Program Files\Microsoft SQL Server'
InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server'
InstanceDir = 'C:\Program Files\Microsoft SQL Server'
InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup'
ASServerMode = 'TABULAR'
ASConfigDir = 'C:\MSOLAP\Config'
ASDataDir = 'C:\MSOLAP\Data'
ASLogDir = 'C:\MSOLAP\Log'
ASBackupDir = 'C:\MSOLAP\Backup'
ASTempDir = 'C:\MSOLAP\Temp'
SourcePath = 'C:\InstallMedia\SQL2016RTM'
UpdateEnabled = 'False'
ProductCoveredbySA = $true
ForceReboot = $false
SqlTempdbFileCount = 4
SqlTempdbFileSize = 1024
SqlTempdbFileGrowth = 512
SqlTempdbLogFileSize = 128
SqlTempdbLogFileGrowth = 64

PsDscRunAsCredential = $SqlInstallCredential

DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45'
}
#endregion Install SQL Server
}
}
Loading

0 comments on commit dd56306

Please sign in to comment.