DLM Automation

Test-DlmDatabaseConnection

Test-DlmDatabaseConnection

Checks a DatabaseConnection object can connect to the database correctly.

Syntax

Test-DlmDatabaseConnection [-InputObject] <DatabaseConnection> [<CommonParameters>]

Description

The Test-DlmDatabaseConnection cmdlet checks that the details in a DatabaseConnection object produced by the New-DlmDatabaseConnection cmdlet can be used to connect to the specified database.

If Test-DlmDatabaseConnection can't connect to the database, it raises an error.

After testing the connection, the cmdlet pipes out the input DatabaseConnection object. This allows you to use Test-DlmDatabaseConnection in a chain of cmdlets.

Parameters

-InputObject <RedGate.DLMAutomation.Compare.SchemaSources.DatabaseConnection>

The Database Connection object or database connection string that identifies the connection to test. See New-DlmDatabaseConnection for details.

Aliases None
Required?true
Position?0
Default Value None
Accept Pipeline Inputtrue (ByValue)
Accept Wildcard Charactersfalse

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see http://technet.microsoft.com/en-us/library/hh847884.aspx.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • RedGate.DLMAutomation.Compare.SchemaSources.DatabaseConnection

    The Database Connection object or database connection string that identifies the connection to test. See New-DlmDatabaseConnection for details.

Return values

The output type is the type of the objects that the cmdlet emits.

  • RedGate.DLMAutomation.Compare.SchemaSources.DatabaseConnection

Examples

---------- EXAMPLE 1 ----------

$connection = New-DlmDatabaseConnection -ServerInstance "prod01\sql2014" -Database "Production" -Username "sa" -Password "P@ssw0rd"
Test-DlmDatabaseConnection $connection

This example shows how to use the Test-DlmDatabaseConnection cmdlet to check that a Database Connection object can connect to a database.

The New-DlmDatabaseConnection cmdlet creates a Database Connection object, $connection. This contains the details needed to connect to the database, Production, on prod01\sql2014. The Test-DlmDatabaseConnection cmdlet then checks these details can be used to connect to Production.

If Test-DlmDatabaseConnection can't connect to the database, you must check the connection details, and create a new Database Connection object with the correct details.

---------- EXAMPLE 2 ----------

$connection = New-DlmDatabaseConnection -ServerInstance "prod01\sql2014" -Database "Production" -Username "sa" -Password "P@ssw0rd" | Test-DlmDatabaseConnection

This example show how to pass a Database Connection object through the pipeline to the Test-DlmDatabaseConnection cmdlet.

The New-DlmDatabaseConnection cmdlet creates a Database Connection object. This is piped to the Test-DlmDatabaseConnection cmdlet.

Test-DlmDatabaseConnection checks that it can connect to the database, Production, using the Database Connection object. It then pipes the same Database Connection object out. This allows it to be assigned to the $connection variable.


Didn't find what you were looking for?