commands

^

Export-DbaCredential

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

 

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

Synopsis

Exports credentials INCLUDING PASSWORDS, unless specified otherwise, to sql file.

Description

Exports credentials INCLUDING PASSWORDS, unless specified otherwise, to sql file.

Requires remote Windows access if exporting the password.

Syntax

Export-DbaCredential
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-Identity] <String[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Credential] <PSCredential>]
    [[-Path] <String>]
    [[-FilePath] <String>]
    [-ExcludePassword]
    [-Append]
    [[-InputObject] <Credential[]>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Export-DbaCredential -SqlInstance sql2017 -Path C:\temp\cred.sql

Exports credentials, including passwords, from sql2017 to the file C:\temp\cred.sql

Optional Parameters

-SqlInstance

The target SQL Server instance or instances.

Alias
Required False
Pipeline false
Default Value
-Identity

The credentials to export. If unspecified, all credentials will be exported.

Alias
Required False
Pipeline false
Default Value
-SqlCredential

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
-Credential

Login to the target OS using alternative credentials. Accepts credential objects (Get-Credential)

Alias
Required False
Pipeline false
Default Value
-Path

The path to the directory that will contain the exported sql file.

Alias
Required False
Pipeline false
Default Value (Get-DbatoolsConfigValue -FullName 'Path.DbatoolsExport')
-FilePath

The specific path to a file which will contain the output.

Alias OutFile,FileName
Required False
Pipeline false
Default Value
-ExcludePassword

Exports the SQL credential without any sensitive information.

Alias
Required False
Pipeline false
Default Value False
-Append

Append to Path

Alias
Required False
Pipeline false
Default Value False
-InputObject

Allow credentials to be piped in from Get-DbaCredential

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