Skip to content

Commit dd56306

Browse files
authored
Added New parameter ProductCoveredbySA that is introduced in SQL 2022 (#2044)
- SqlSetup - Added new parameter ProductCoveredbySA which is introduced in SQL 2022.
1 parent 3c30929 commit dd56306

File tree

6 files changed

+277
-11
lines changed

6 files changed

+277
-11
lines changed

CHANGELOG.md

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

88
### Added
99

10+
- SqlSetup
11+
- Added new parameter ProductCoveredbySA which is introduced in SQL 2022.
12+
13+
### Added
14+
1015
- `Connect-SqlDscDatabaseEngine`
1116
- Added integration test for the command.
1217
- `Uninstall-SqlDscServer`

source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ function Get-TargetResource
176176
UseEnglish = $UseEnglish
177177
ServerName = $ServerName
178178
SqlVersion = $null
179+
ProductCoveredBySA = $null
179180
}
180181

181182
<#
@@ -318,6 +319,16 @@ function Get-TargetResource
318319
$getTargetResourceReturnValue.SqlTempdbLogFileGrowth = $currentTempDbProperties.SqlTempdbLogFileGrowth
319320
}
320321

322+
if ($sqlVersion -ge 16)
323+
{
324+
# Grab the value of ProductCoveredBySA from the registry based on the instance
325+
$getRegistryPropertyParams = @{
326+
Path = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL$($SqlVersion).$($InstanceName)\Setup"
327+
Name = 'IsProductCoveredBySA'
328+
}
329+
$getTargetResourceReturnValue.ProductCoveredBySA = Get-RegistryPropertyValue @getRegistryPropertyParams
330+
}
331+
321332
# Get all members of the sysadmin role.
322333
$sqlSystemAdminAccounts = Get-SqlRoleMembers -RoleName 'sysadmin' -ServerName $sqlHostName -InstanceName $InstanceName
323334
$getTargetResourceReturnValue.SQLSysAdminAccounts = $sqlSystemAdminAccounts
@@ -518,6 +529,11 @@ function Get-TargetResource
518529
.PARAMETER ProductKey
519530
Product key for licensed installations.
520531
532+
.PARAMETER ProductCoveredBySA
533+
Specifies the license coverage for SQL Server. True indicates it's covered under Software Assurance or SQL Server subscription.
534+
False, or omitting the parameter, indicates it's covered under a SQL Server license.
535+
Default value is False.
536+
521537
.PARAMETER UpdateEnabled
522538
Enabled updates during installation.
523539
@@ -748,6 +764,10 @@ function Set-TargetResource
748764
[System.String]
749765
$ProductKey,
750766

767+
[Parameter()]
768+
[System.Boolean]
769+
$ProductCoveredBySA,
770+
751771
[Parameter()]
752772
[System.String]
753773
$UpdateEnabled,
@@ -1290,6 +1310,12 @@ function Set-TargetResource
12901310
$setupArguments['FailoverClusterIPAddresses'] = $clusterIPAddresses
12911311
}
12921312

1313+
# Add Parameter ProductCoveredBySA
1314+
if ($PSBoundParameters.ContainsKey('ProductCoveredBySA'))
1315+
{
1316+
$setupArguments['ProductCoveredBySA'] = $ProductCoveredBySA
1317+
}
1318+
12931319
# Add standard install arguments
12941320
$setupArguments += @{
12951321
Quiet = $true
@@ -1767,6 +1793,13 @@ function Set-TargetResource
17671793
.PARAMETER ProductKey
17681794
Product key for licensed installations.
17691795
1796+
.PARAMETER ProductCoveredBySA
1797+
Specifies the license coverage for SQL Server. True indicates it's covered under Software Assurance or SQL Server subscription.
1798+
False, or omitting the parameter, indicates it's covered under a SQL Server license.
1799+
Default value is False.
1800+
1801+
Not used in Test-TargetResource.
1802+
17701803
.PARAMETER UpdateEnabled
17711804
Enabled updates during installation.
17721805
@@ -2005,6 +2038,10 @@ function Test-TargetResource
20052038
[System.String]
20062039
$ProductKey,
20072040

2041+
[Parameter()]
2042+
[System.Boolean]
2043+
$ProductCoveredBySA,
2044+
20082045
[Parameter()]
20092046
[System.String]
20102047
$UpdateEnabled,

source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DSC_SqlSetup : OMI_BaseResource
1010
[Key, Description("Specifies the name of the instance to be installed.")] String InstanceName;
1111
[Write, Description("_SQL Server_ instance ID (if different from parameter **InstanceName**).")] String InstanceID;
1212
[Write, Description("Product key for licensed installations.")] String ProductKey;
13+
[Write, Description("Specifies the Software Assurance license coverage for SQL Server instance.")] Boolean ProductCoveredbySA;
1314
[Write, Description("Enabled updates during installation.")] String UpdateEnabled;
1415
[Write, Description("Path to the source of updates to be applied during installation.")] String UpdateSource;
1516
[Write, Description("Enable customer experience reporting.")] String SQMReporting;
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<#
2+
.DESCRIPTION
3+
This example shows how to install a default instance of SQL Server, and
4+
Analysis Services in Tabular mode, on a single server.
5+
It contains configurations that apply to Sql Server 2022 or later only.
6+
7+
.NOTES
8+
SQL Server setup is run using the SYSTEM account. Even if SetupCredential is provided
9+
it is not used to install SQL Server at this time (see issue #139).
10+
#>
11+
12+
Configuration Example
13+
{
14+
[CmdletBinding()]
15+
param
16+
(
17+
[Parameter(Mandatory = $true)]
18+
[ValidateNotNullOrEmpty()]
19+
[System.Management.Automation.PSCredential]
20+
$SqlInstallCredential,
21+
22+
[Parameter()]
23+
[ValidateNotNullOrEmpty()]
24+
[System.Management.Automation.PSCredential]
25+
$SqlAdministratorCredential = $SqlInstallCredential,
26+
27+
[Parameter(Mandatory = $true)]
28+
[ValidateNotNullOrEmpty()]
29+
[System.Management.Automation.PSCredential]
30+
$SqlServiceCredential,
31+
32+
[Parameter()]
33+
[ValidateNotNullOrEmpty()]
34+
[System.Management.Automation.PSCredential]
35+
$SqlAgentServiceCredential = $SqlServiceCredential
36+
)
37+
38+
Import-DscResource -ModuleName 'xPSDesiredStateConfiguration' -ModuleVersion '9.1.0'
39+
Import-DscResource -ModuleName 'SqlServerDsc'
40+
41+
node localhost
42+
{
43+
#region Install prerequisites for SQL Server
44+
WindowsFeature 'NetFramework35'
45+
{
46+
Name = 'NET-Framework-Core'
47+
Source = '\\fileserver.company.local\images$\Win2k12R2\Sources\Sxs' # Assumes built-in Everyone has read permission to the share and path.
48+
Ensure = 'Present'
49+
}
50+
51+
WindowsFeature 'NetFramework45'
52+
{
53+
Name = 'NET-Framework-45-Core'
54+
Ensure = 'Present'
55+
}
56+
#endregion Install prerequisites for SQL Server
57+
58+
#region Install SQL Server
59+
SqlSetup 'InstallDefaultInstance'
60+
{
61+
InstanceName = 'MSSQLSERVER'
62+
Features = 'SQLENGINE,AS'
63+
SQLCollation = 'SQL_Latin1_General_CP1_CI_AS'
64+
SQLSvcAccount = $SqlServiceCredential
65+
AgtSvcAccount = $SqlAgentServiceCredential
66+
ASSvcAccount = $SqlServiceCredential
67+
SQLSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
68+
ASSysAdminAccounts = 'COMPANY\SQL Administrators', $SqlAdministratorCredential.UserName
69+
InstallSharedDir = 'C:\Program Files\Microsoft SQL Server'
70+
InstallSharedWOWDir = 'C:\Program Files (x86)\Microsoft SQL Server'
71+
InstanceDir = 'C:\Program Files\Microsoft SQL Server'
72+
InstallSQLDataDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
73+
SQLUserDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
74+
SQLUserDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
75+
SQLTempDBDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
76+
SQLTempDBLogDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data'
77+
SQLBackupDir = 'C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup'
78+
ASServerMode = 'TABULAR'
79+
ASConfigDir = 'C:\MSOLAP\Config'
80+
ASDataDir = 'C:\MSOLAP\Data'
81+
ASLogDir = 'C:\MSOLAP\Log'
82+
ASBackupDir = 'C:\MSOLAP\Backup'
83+
ASTempDir = 'C:\MSOLAP\Temp'
84+
SourcePath = 'C:\InstallMedia\SQL2016RTM'
85+
UpdateEnabled = 'False'
86+
ProductCoveredbySA = $true
87+
ForceReboot = $false
88+
SqlTempdbFileCount = 4
89+
SqlTempdbFileSize = 1024
90+
SqlTempdbFileGrowth = 512
91+
SqlTempdbLogFileSize = 128
92+
SqlTempdbLogFileGrowth = 64
93+
94+
PsDscRunAsCredential = $SqlInstallCredential
95+
96+
DependsOn = '[WindowsFeature]NetFramework35', '[WindowsFeature]NetFramework45'
97+
}
98+
#endregion Install SQL Server
99+
}
100+
}

source/Examples/Resources/SqlSetup/8-UsingSkipRuleDuringInstall.ps1 renamed to source/Examples/Resources/SqlSetup/9-UsingSkipRuleDuringInstall.ps1

File renamed without changes.

0 commit comments

Comments
 (0)