Skip to content

Copy-DbaDbTableData Fails in Version 2.7.25 Exception calling "ClearAndInitialize" #10181

@MarkusAngenendt

Description

@MarkusAngenendt

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

PSMessageDetails      :
Exception             : System.Management.Automation.MethodInvocationException: Ausnahme beim Aufrufen von
                        "ClearAndInitialize" mit 2 Argument(en):  "unknown property IndexSpaceUsed" --->
                        Microsoft.SqlServer.Management.Sdk.Sfc.UnknownPropertyEnumeratorException: unknown property
                        IndexSpaceUsed
                           bei Microsoft.SqlServer.Management.Sdk.Sfc.EnumObject.GetProperty(String name,
                        ObjectPropertyUsages usage)
                           bei Microsoft.SqlServer.Management.Smo.SqlObjectBase.AddRequestProperties()
                           bei Microsoft.SqlServer.Management.Smo.SqlObjectBase.RetrieveParentRequestLinks(SqlRequest
                        sr)
                           bei Microsoft.SqlServer.Management.Smo.SqlObjectBase.RetrieveParentRequest()
                           bei Microsoft.SqlServer.Management.Sdk.Sfc.Environment.InitObjects(Request req)
                           bei Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData(Request req, Object ci)
                           bei Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetData(Object connectionInfo,
                        Request request)
                           bei Microsoft.SqlServer.Management.Smo.ExecutionManager.GetEnumeratorDataReader(Request req)
                           bei Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitChildLevel(Urn levelFilter,
                        ScriptingPreferences sp, Boolean forScripting, IEnumerable`1 extraFields)
                           bei Microsoft.SqlServer.Management.Smo.SmoCollectionBase.InitializeChildCollection(Boolean
                        refresh, ScriptingPreferences sp, String filterQuery, IEnumerable`1 extraFields)
                           bei Microsoft.SqlServer.Management.Smo.SmoCollectionBase.ClearAndInitialize(String
                        filterQuery, IEnumerable`1 extraFields)
                           bei CallSite.Target(Closure , CallSite , Object , Object , String[] )
                           --- Ende der internen Ausnahmestapelüberwachung ---
                           bei
                        System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception
                        exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
                           bei CallSite.Target(Closure , CallSite , Object , Object , String[] )
                           bei System.Management.Automation.Interpreter.DynamicInstruction`4.Run(InterpretedFrame
                        frame)
                           bei
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : UnknownPropertyEnumeratorException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : bei Get-DbaDbTable<Process>, <Keine Datei>: Zeile 31514
                        bei Copy-DbaDbTableData<Process>, <Keine Datei>: Zeile 10265
                        bei <ScriptBlock>, <Keine Datei>: Zeile 1
PipelineIterationInfo : {}

Steps to Reproduce

# provide your command(s) executed pertaining to dbatools
# please include variable values (redacted or fake if needed) for reference

import-module dbatools -RequiredVersion 2.7.25
$localcon = Connect-DbaInstance -SqlInstance "sql01.domain.local" -TrustServerCertificate
$azcon = Connect-DbaInstance -SqlInstance "azsql.database.windows.net" -SqlCredential (Get-Credential)

Copy-DbaDbTableData `
-SqlInstance $localcon `
-Destination $azcon `
-Database "Azure" `
-DestinationDatabase "azsqldb" `
-Table "Tablename" `
-DestinationTable "Tablename" `
-KeepNulls `
-KeepIdentity

Please confirm that you are running the most recent version of dbatools

2.7.25

Other details or mentions

In Version 2.7.24 the CmdLet Copy-DbaDbTableData works fine.

I think the Issue comes from this Change:

Get-DbaDbTable: Optimize usage of ClearAndInitialize by @andreasjordan in #10157

What PowerShell host was used when producing this error

Windows PowerShell (powershell.exe)

PowerShell Host Version

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.17763.8276                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.17763.8276                                                                         
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 

SQL Server Edition and Build number

Source:
Microsoft SQL Server 2019 (RTM-GDR) (KB5068405) - 15.0.2155.2 (X64) Oct 7 2025 21:11:52 Copyright (C) 2019 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)

Destination:
Microsoft SQL Azure (RTM) - 12.0.2000.8 Jan 2 2026 13:26:31 Copyright (C) 2025 Microsoft Corporation

.NET Framework Version

PSChildName Version
----------- -------
Client      4.8.03761
Full        4.8.03761
Client      4.0.0.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions