Setting up database connections
Published 10 March 2016
If you use a database as a source for any of the DLM Automation cmdlets, you'll first need to use the New-DlmDatabaseConnection cmdlet to set up the connection details to the database. You can also use the Test-DlmDatabaseConnection cmdlet to check the connection works. This page provides an overview of these cmdlets.
New-DlmDatabaseConnection
Use this cmdlet to specify the connection details for a database, which you can then use as the input for other DLM Automation cmdlets.
Example
New-DlmDatabaseConnection -ServerInstance "test01\sql2014" -Database "WidgetIntegration"
If you aren't using Windows Authentication, you'll also need to specify the username and password for the SQL Server account:
Example
New-DlmDatabaseConnection -ServerInstance "test01\sql2014" -Database "WidgetIntegration" -Username "sa" -Password "P@ssw0rd"
By assigning the output of New-DlmDatabaseConnection to a variable, you can reuse this as the input for another cmdlet:
Example
$testdb = New-DlmDatabaseConnection -ServerInstance "test01\sql2014" -Database "WidgetIntegration" Sync-DlmDatabaseSchema -Source "C:\Work\scripts" -Target $testdb
In the example above, we've assigned the connection to our test database to the variable, $testdb. We've then used this as the input for the Sync-DlmDatabaseSchema cmdlet.
We'll look at Sync-DlmDataseSchema in more detail later in this tutorial.
Test-DlmDatabaseConnection
Use this cmdlet to check the connection you specified in the New-DlmDatabaseConnection cmdlet works. 
Example
$testdb = New-DlmDatabaseConnection -ServerInstance "test01\sql2014" -Database "Test" | Test-DlmDatabaseConnection
In the example above, we've used the pipe (|) symbol to take the output of New-DlmDatabaseConnection and input it into Test-DlmDatabaseConnection.
If New-DlmDatabaseConnection can't connect to the database, it raises an error.
What next?
You're now ready to learn how to use New-DlmDatabaseConnection and Test-DlmDatabaseConnection with other DLM Automation cmdlets, to set up Continuous Integration.
Cmdlet reference
For full details about all the DLM Automation cmdlets, see the DLM Automation cmdlet reference.