Skip to content

Commit

Permalink
version 16
Browse files Browse the repository at this point in the history
  • Loading branch information
sarav921spec committed Sep 20, 2024
1 parent 92090ba commit 7079db5
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions source/DSCResources/DSC_SqlSetup/DSC_SqlSetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function Get-TargetResource

[Parameter()]
[System.String]
$SqlVersion
$SqlVersion,
)

if ($Action -eq 'Upgrade' -and $PSBoundParameters.ContainsKey('SqlVersion'))
Expand Down Expand Up @@ -265,6 +265,7 @@ function Get-TargetResource
$getTargetResourceReturnValue.SQLBackupDir = $currentSqlEngineProperties.SQLBackupDir
$getTargetResourceReturnValue.IsClustered = $currentSqlEngineProperties.IsClustered
$getTargetResourceReturnValue.SecurityMode = $currentSqlEngineProperties.SecurityMode
$getTargetResourceReturnValue.ProductCoveredBySA = $currentSqlEngineProperties.ProductCoveredBySA

Write-Verbose -Message $script:localizedData.EvaluateReplicationFeature

Expand Down Expand Up @@ -319,14 +320,6 @@ function Get-TargetResource
$getTargetResourceReturnValue.SqlTempdbLogFileGrowth = $currentTempDbProperties.SqlTempdbLogFileGrowth
}

if ($sqlVersion -ge 16)
{
# Grab the value of ProductCoveredBySA from the registry based on the instance
$ProductCoveredBySARegistryPath = "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL$($SqlVersion).$($InstanceName)\Setup"

$getTargetResourceReturnValue.ProductCoveredBySA = Get-RegistryPropertyValue -Path $ProductCoveredBySARegistryPath -Name "IsProductCoveredBySA"
}

# Get all members of the sysadmin role.
$sqlSystemAdminAccounts = Get-SqlRoleMembers -RoleName 'sysadmin' -ServerName $sqlHostName -InstanceName $InstanceName
$getTargetResourceReturnValue.SQLSysAdminAccounts = $sqlSystemAdminAccounts
Expand Down Expand Up @@ -527,11 +520,6 @@ 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 @@ -717,6 +705,9 @@ function Get-TargetResource
will not be used to evaluate version. Although, if the setup action is
`Upgrade` then setting this parameter will throw an exception as the version
from the install media is required.
.PARAMETER PRODUCTCOVEREDBYSA
Specifies the license coverage for SQL Server.
#>
function Set-TargetResource
{
Expand Down Expand Up @@ -762,10 +753,6 @@ function Set-TargetResource
[System.String]
$ProductKey,

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

[Parameter()]
[System.String]
$UpdateEnabled,
Expand Down Expand Up @@ -990,7 +977,11 @@ function Set-TargetResource

[Parameter()]
[System.String]
$SqlVersion
$SqlVersion,

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

if ($Action -eq 'Upgrade' -and $PSBoundParameters.ContainsKey('SqlVersion'))
Expand Down Expand Up @@ -1308,17 +1299,12 @@ function Set-TargetResource
$setupArguments['FailoverClusterIPAddresses'] = $clusterIPAddresses
}

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

# Add standard install arguments
$setupArguments += @{
Quiet = $true
IAcceptSQLServerLicenseTerms = $true
Action = $Action
ProductCoveredBySA = $true
}

$argumentVars = @(
Expand Down Expand Up @@ -1791,13 +1777,6 @@ 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 @@ -1991,6 +1970,9 @@ function Set-TargetResource
will not be used to evaluate version. Although, if the setup action is
`Upgrade` then setting this parameter will throw an exception as the version
from the install media is required.
.PARAMETER PRODUCTCOVEREDBYSA
Specifies the license coverage for SQL Server.
#>
function Test-TargetResource
{
Expand Down Expand Up @@ -2036,10 +2018,6 @@ function Test-TargetResource
[System.String]
$ProductKey,

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

[Parameter()]
[System.String]
$UpdateEnabled,
Expand Down Expand Up @@ -2264,7 +2242,11 @@ function Test-TargetResource

[Parameter()]
[System.String]
$SqlVersion
$SqlVersion,

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

if ($Action -eq 'Upgrade' -and $PSBoundParameters.ContainsKey('SqlVersion'))
Expand Down

0 comments on commit 7079db5

Please sign in to comment.