dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Test-DbaLinkedServerConnection

Tests the connection to a linked server. If the test is unsuccessful the command returns the reason of the failure.

Screenshots

Examples

Test all Linked Servers for the SQL Server instance DEV01.

Test-DbaLinkedServerConnection -SqlInstance DEV01

Test all Linked Servers for the SQL Server instance sql2016 and output results to file.

Test-DbaLinkedServerConnection -SqlInstance sql2016 | Out-File C:\temp\results.txt

Test all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012.

Test-DbaLinkedServerConnection -SqlInstance sql2016, sql2014, sql2012

Test all Linked Servers for the SQL Server instances sql2016, sql2014 and sql2012 using SQL login credentials.

$servers = “sql2016″,”sql2014″,”sql2012”
$servers | Test-DbaLinkedServerConnection -SqlCredential (Get-Credential sqladmin)

Author

This command was created by Thomas LaRock, SQL Server MCM and MVP. You can find Thomas on Twitter and his website.

Get-Help

From PowerShell, execute Get-Help Test-DbaLinkedServerConnection -Detailed for more information on this function.

Source Code

Want to see the source code? View Test-DbaLinkedServerConnection.ps1 on GitHub
 

Related commands