Connect-BcpDatabase
Establishes a connection to an existing powerLoad Database.
Syntax
Connect-BcpDatabase -Database <string> [-ConnectionString <string>] [<CommonParameters>]
Parameters
Type |
Name |
Description |
Default value |
Optional |
|---|---|---|---|---|
string |
ConnectionString |
Connection details for the SQL Server instance, usually the one running on the ADMS server. |
Data Source=(local)\AUTODESKVAULT;User ID=sa;Password=AutodeskVault@26200;Encrypt=false |
yes |
string |
Database |
Name of an already existing powerLoad DB. Previously imported databases start with the prefix |
no |
Return type
powerLoad DB ← On success, the cmdlet returns connection details for the connected powerLoad Database, including the database name and a usable connection string.
empty ← On failure the Exception/ErrorMessage can be accessed using $Error.
Remarks
The cmdlet connects to the SQL Server instance that typically runs directly on the current ADMS environment. For best performance, this uses shared memory.
The specified Database is set as the default database for the session. This means that any subsequent Invoke-Sqlcmd commands will automatically target this powerLoad DB, allowing queries to tables without specifying the database name explicitly.
Examples
Restoring customer DB locally
$backupFile = 'C:\Temp\powerLoad_CustomersVault_2025-10-17'
$databaseName = [System.IO.Path]::GetFileNameWithoutExtension($backupFile)
Invoke-Sqlcmd -ServerInstance '.\AUTODESKVAULT' -Username 'sa' -Password 'AutodeskVault@26200' -Query @"
RESTORE DATABASE [$databaseName] FROM DISK='$backupFile' WITH REPLACE
"@
$db = Connect-BcpDatabase -Database $databaseName
Error handling, analyze why connecting to the powerLoad DB failed
$db = Connect-BcpDatabase -Database 'powerLoad_MySourceVault_2025-10-17' -ConnectionString 'Data Source=ADMSSERVER01;Persist Security Info=True;User ID=sa;Password=AutodeskVault@26200;Pooling=False;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=True'
if(-not $db) {
$Error[0].Exception # Returns "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections."
}