Author | Jess Pomfret (@jpomfret) |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Backup-DbaDbCertificate on GitHub.
Want to see the Bill Of Health for this command? Check out Backup-DbaDbCertificate.
Exports database certificates from SQL Server using SMO.
Exports database certificates from SQL Server using SMO and outputs the .cer and .pvk files.
Backup-DbaDbCertificate
[-SqlCredential <PSCredential>]
[-EncryptionPassword <SecureString>]
[-DecryptionPassword <SecureString>]
[-Path <FileInfo>]
[-Suffix <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Backup-DbaDbCertificate -SqlInstance <DbaInstanceParameter[]>
[-SqlCredential <PSCredential>]
[-Certificate <Object[]>]
[-Database <Object[]>]
[-ExcludeDatabase <Object[]>]
[-EncryptionPassword <SecureString>]
[-DecryptionPassword <SecureString>]
[-Path <FileInfo>]
[-Suffix <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Backup-DbaDbCertificate
[-SqlCredential <PSCredential>]
[-EncryptionPassword <SecureString>]
[-DecryptionPassword <SecureString>]
[-Path <FileInfo>]
[-Suffix <String>]
[-InputObject <Certificate[]>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1
Exports all the certificates on the specified SQL Server to the default data path for the instance.
PS C:\> $cred = Get-Credential sqladmin
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -SqlCredential $cred
Connects using sqladmin credential and exports all the certificates on the specified SQL Server to the default data path for the instance.
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -Certificate Certificate1
Exports only the certificate named Certificate1 on the specified SQL Server to the default data path for the instance.
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -Database AdventureWorks
Exports only the certificates for AdventureWorks on the specified SQL Server to the default data path for the instance.
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -ExcludeDatabase AdventureWorks
Exports all certificates except those for AdventureWorks on the specified SQL Server to the default data path for the instance.
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -Path \\Server1\Certificates -EncryptionPassword (Get-Credential NoUsernameNeeded).Password
Exports all the certificates and private keys on the specified SQL Server.
PS C:\> $EncryptionPassword = (Get-Credential NoUsernameNeeded).Password
PS C:\> $DecryptionPassword = (Get-Credential NoUsernameNeeded).Password
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -EncryptionPassword $EncryptionPassword -DecryptionPassword $DecryptionPassword
Exports all the certificates on the specified SQL Server using the supplied DecryptionPassword, since an EncryptionPassword is specified private keys are also exported.
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -Path \\Server1\Certificates
Exports all certificates on the specified SQL Server to the specified path.
PS C:\> Backup-DbaDbCertificate -SqlInstance Server1 -Suffix DbaTools
Exports all certificates on the specified SQL Server to the specified path, appends DbaTools to the end of the filenames.
PS C:\> Get-DbaDbCertificate -SqlInstance sql2016 | Backup-DbaDbCertificate
Exports all certificates found on sql2016 to the default data directory.
The target SQL Server instance or instances. This can be a collection and receive pipeline input to allow the function to be executed against multiple SQL Server instances.
Alias | |
Required | True |
Pipeline | false |
Default Value |
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Exports certificate that matches the name(s).
Alias | |
Required | False |
Pipeline | false |
Default Value |
Exports the encryptor for specific database(s).
Alias | |
Required | False |
Pipeline | false |
Default Value |
Database(s) to skip when exporting encryptors.
Alias | |
Required | False |
Pipeline | false |
Default Value |
A string value that specifies the secure password to encrypt the private key.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Secure string used to decrypt the private key.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The path to output the files to. The path is relative to the SQL Server itself. If no path is specified, the default data directory will be used.
Alias | |
Required | False |
Pipeline | false |
Default Value |
The suffix of the filename of the exported certificate.
Alias | |
Required | False |
Pipeline | false |
Default Value |
Enables piping from Get-DbaDbCertificate
Alias | |
Required | False |
Pipeline | true (ByValue) |
Default Value |
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 |
If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |