commands

^

Set-DbaNetworkCertificate

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

 

Synopsis

Sets the network certificate for SQL Server instance

Description

Sets the network certificate for SQL Server instance. This setting is found in Configuration Manager.

This command also grants read permissions for the service account on the certificate's private key.

References: https://www.itprotoday.com/sql-server/7-steps-ssl-encryption https://azurebi.jppp.org/2016/01/23/using-lets-encrypt-certificates-for-secure-sql-server-connections/ https://blogs.msdn.microsoft.com/sqlserverfaq/2016/09/26/creating-and-registering-ssl-certificates/

Syntax

Set-DbaNetworkCertificate
    [-SqlInstance <DbaInstanceParameter[]>]
    [-Credential <PSCredential>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Set-DbaNetworkCertificate
    [-SqlInstance <DbaInstanceParameter[]>]
    [-Credential <PSCredential>] -Certificate <X509Certificate2>
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Set-DbaNetworkCertificate
    [-SqlInstance <DbaInstanceParameter[]>]
    [-Credential <PSCredential>] -Thumbprint <String>
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> New-DbaComputerCertificate | Set-DbaNetworkCertificate -SqlInstance localhost\SQL2008R2SP2

Creates and imports a new certificate signed by an Active Directory CA on localhost then sets the network certificate for the SQL2008R2SP2 to that newly created certificate.

Example: 2
PS C:\> Set-DbaNetworkCertificate -SqlInstance sql1\SQL2008R2SP2 -Thumbprint 1223FB1ACBCA44D3EE9640F81B6BA14A92F3D6E2

Sets the network certificate for the SQL2008R2SP2 instance to the certificate with the thumbprint of 1223FB1ACBCA44D3EE9640F81B6BA14A92F3D6E2 in LocalMachine\My on sql1

Required Parameters

-Certificate

The target certificate object

Alias
Required True
Pipeline true (ByValue)
Default Value
-Thumbprint

The thumbprint of the target certificate

Alias
Required True
Pipeline true (ByPropertyName)
Default Value

Optional Parameters

-SqlInstance

The target SQL Server instance or instances. Defaults to localhost.

Alias ComputerName
Required False
Pipeline true (ByPropertyName)
Default Value
-Credential

Allows you to login to the computer (not sql instance) using alternative credentials.

Alias
Required False
Pipeline true (ByPropertyName)
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
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value

 

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