Skip to content

Commit

Permalink
Get-DbaProductKey - Support SQL Server 2022 (dataplat#8952)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasjordan authored Jun 7, 2023
1 parent 0043221 commit 4e4551c
Showing 1 changed file with 3 additions and 30 deletions.
33 changes: 3 additions & 30 deletions public/Get-DbaProductKey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ function Get-DbaProductKey {

switch ($versionMajor) {
9 {
$sqlversion = "SQL Server 2005 $servicePack"
$findkeys = $reg.OpenSubKey("$($instanceReg.Path)\ProductID", $false)
foreach ($findkey in $findkeys.GetValueNames()) {
if ($findkey -like "DigitalProductID*") {
Expand All @@ -118,34 +117,10 @@ function Get-DbaProductKey {
}
}
10 {
$sqlversion = "SQL Server 2008 $servicePack"
if ($server.VersionMinor -eq 50) {
$sqlversion = "SQL Server 2008 R2 $servicePack"
}
$key = @("$($instanceReg.Path)\Setup\DigitalProductID")
}
11 {
$key = @("$($instanceReg.Path)\Setup\DigitalProductID", "$($instanceReg.Path)\ClientSetup\DigitalProductID")
$sqlversion = "SQL Server 2012 $servicePack"
}
12 {
$key = @("$($instanceReg.Path)\Setup\DigitalProductID", "$($instanceReg.Path)\ClientSetup\DigitalProductID")
$sqlversion = "SQL Server 2014 $servicePack"
}
13 {
$key = @("$($instanceReg.Path)\Setup\DigitalProductID", "$($instanceReg.Path)\ClientSetup\DigitalProductID")
$sqlversion = "SQL Server 2016 $servicePack"
}
14 {
$key = @("$($instanceReg.Path)\Setup\DigitalProductID", "$($instanceReg.Path)\ClientSetup\DigitalProductID")
$sqlversion = "SQL Server 2017 $servicePack"
}
15 {
$key = @("$($instanceReg.Path)\Setup\DigitalProductID", "$($instanceReg.Path)\ClientSetup\DigitalProductID")
$sqlversion = "SQL Server 2019 $servicePack"
}
default {
Stop-Function -Message "SQL version not currently supported." -Continue
$key = @("$($instanceReg.Path)\Setup\DigitalProductID", "$($instanceReg.Path)\ClientSetup\DigitalProductID")
}
}
if ($edition -notlike "*Express*") {
Expand Down Expand Up @@ -175,8 +150,7 @@ function Get-DbaProductKey {
}

[pscustomobject]@{
Version = $sqlversion
Key = $sqlkey
Key = $sqlkey
}
$reg.Close()
}
Expand All @@ -202,7 +176,6 @@ function Get-DbaProductKey {
Stop-Function -Message "Failure" -Category ConnectionError -ErrorRecord $_ -Target $instanceReg.SqlInstance -Continue
}

$servicePack = $server.ProductLevel
$versionMajor = $server.VersionMajor
Write-Message -Level Debug -Message "$instance $instanceName version is $($server.VersionMajor)"

Expand All @@ -216,7 +189,7 @@ function Get-DbaProductKey {
ComputerName = $server.ComputerName
InstanceName = $server.ServiceName
SqlInstance = $server.DomainInstanceName
Version = $results.Version
Version = $server.GetSqlServerVersionName()
Edition = $server.Edition
Key = $results.Key
}
Expand Down

0 comments on commit 4e4551c

Please sign in to comment.