internal/functions/Connect-ReplicationDB.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#Helper Function
function Connect-ReplicationDB {
    param (
        [object]$Server,
        [object]$Database
    )

    $repDB = New-Object Microsoft.SqlServer.Replication.ReplicationDatabase

    $repDB.Name = $Database.Name
    $repDB.ConnectionContext = $Server.ConnectionContext.SqlConnectionObject

    if (!$repDB.LoadProperties()) {
        Write-Message -Level Verbose -Message "Skipping $($Database.Name). Failed to load properties correctly."
    }

    return $repDB
}