Skip to content

Commit 3bf5c13

Browse files
fix: Load type extensions via Update-TypeData to avoid conflicts
Use Update-TypeData -ErrorAction SilentlyContinue in the psm1 instead of TypesToProcess in the psd1. This prevents errors when dbatools also loads its own identical type extensions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 41e2f99 commit 3bf5c13

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

dbatools.library.psd1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
# but only in Full .NET because Core does something different
3535
RequiredAssemblies = @()
3636

37-
# Type files (.ps1xml) to be loaded when importing this module
38-
TypesToProcess = @('xml/dbatools.Types.ps1xml')
39-
4037
# Script module or binary module file associated with this manifest.
4138
RootModule = 'dbatools.library.psm1'
4239

dbatools.library.psm1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,11 @@ if (Test-Path $dbatoolsDll) {
339339
} catch {
340340
Write-Error "Could not import dbatools binary module: $($_ | Out-String)"
341341
}
342+
}
343+
344+
# Load type extensions (Query/Invoke on SMO Server/Database, serialization depth for exceptions)
345+
# Use -ErrorAction SilentlyContinue because dbatools may also load identical type data
346+
$typesFile = [IO.Path]::Combine($PSScriptRoot, "xml", "dbatools.Types.ps1xml")
347+
if (Test-Path $typesFile) {
348+
Update-TypeData -PrependPath $typesFile -ErrorAction SilentlyContinue
342349
}

0 commit comments

Comments
 (0)