commands

^

Export-DbaLinkedServer

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

 

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

Synopsis

Exports linked servers INCLUDING PASSWORDS, unless specified otherwise, to sql file.

Description

Exports linked servers INCLUDING PASSWORDS, unless specified otherwise, to sql file.

Requires remote Windows access if exporting the password.

Syntax

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

 

Examples

 

Example: 1
PS C:\> Export-DbaLinkedServer -SqlInstance sql2017 -Path C:\temp\ls.sql

Exports the linked servers, including passwords, from sql2017 to the file C:\temp\ls.sql

Example: 2
PS C:\> Export-DbaLinkedServer -SqlInstance sql2017 -Path C:\temp\ls.sql -ExcludePassword

Exports the linked servers, without passwords, from sql2017 to the file C:\temp\ls.sql

Required Parameters

-SqlInstance

Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2005 or higher.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-LinkedServer

The linked server(s) to export. If unspecified, all linked servers will be processed.

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 linked servers. Accepts credential objects (Get-Credential)

Alias
Required False
Pipeline false
Default Value
-Path

Specifies the directory where the file or files will be exported.

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

Specifies the full file path of the output file.

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

Exports the linked server 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-DbaLinkedServer

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