commands

^

Get-DbaProductKey

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Get-DbaProductKey on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaProductKey.

Synopsis

Retrieves SQL Server product keys from registry data for license compliance and inventory management.

Description

Decodes SQL Server product keys from registry DigitalProductID entries across all installed instances on target computers. This is essential for license compliance auditing, asset inventory during migrations, and generating compliance reports for auditors. The command handles different SQL Server versions (2005+), supports clustered instances, and automatically identifies Express editions that don't require product keys. Works by connecting to each SQL instance to determine version and edition, then accessing registry data remotely to decode the binary product key information.

Syntax

Get-DbaProductKey
    [-ComputerName] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Credential] <PSCredential>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaProductKey -ComputerName winxp, sqlservera, sqlserver2014a, win2k8

Gets SQL Server versions, editions and product keys for all instances within each server or workstation.

Required Parameters

-ComputerName

Specifies the SQL Server instances or computer names to retrieve product keys from. Accepts multiple values for bulk operations.
Use this when you need to audit license compliance across multiple servers or gather product key inventory during migrations.

Alias SqlInstance
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlCredential

This command logs into the SQL instance to gather additional information.
Use this parameter to connect to the discovered SQL instances using alternative credentials. Windows and SQL Authentication supported. Accepts credential objects (Get-Credential)

Alias
Required False
Pipeline false
Default Value
-Credential

Login to the target Windows instance using alternative credentials. Windows Authentication supported. Accepts credential objects (Get-Credential)

Alias
Required False
Pipeline false
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False