Skip to content

Commit 9e87304

Browse files
Load replication libraries before parsing functions with type constraints
Fixes parameter validation test failure where Get-Command returned null because functions with [Microsoft.SqlServer.Replication.*] type constraints couldn't be parsed without the replication DLLs loaded first. Co-authored-by: Chrissy LeMaire <potatoqualitee@users.noreply.github.com>
1 parent 21d5771 commit 9e87304

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

dbatools.psm1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ if (-not (Test-Path -Path "$script:PSModuleRoot\dbatools.dat") -or $script:seria
184184

185185
Write-ImportTime -Text "Loading internal commands via dotsource"
186186

187+
# Load replication libraries before dot-sourcing functions with replication type constraints
188+
# This is required for Remove-DbaReplArticle and Remove-DbaReplPublication which have
189+
# [Microsoft.SqlServer.Replication.*] type constraints in their parameters
190+
try {
191+
Add-ReplicationLibrary -ErrorAction SilentlyContinue
192+
} catch {
193+
# Silently ignore if replication libraries can't be loaded
194+
# The individual commands will handle this when they're executed
195+
}
196+
187197
# All exported functions
188198
foreach ($file in (Get-ChildItem -Path "$script:PSModuleRoot/public/" -Recurse -Filter *.ps1)) {
189199
. $file.FullName

0 commit comments

Comments
 (0)