PowerShell Late Binding Error when trying to retrieve data from a nested DataTable

Hello Everyone,

Recently I have started implementing SAP GUI Scripting via PowerShell with the help of forum post by @StefanSchnell, everything works great for the most parts and I have found improvements of about 70% from I previously achieved by automatization via UiPath Activities.

However, I have ran into a roadblock that I cannot solve for the life of me. When using the “Invoke PowerShell” activity and trying to retrieve data from a nested DataTable I run into a “Late Binding” error, here’s an example of the PowerShell code below:

#-Init Data Table---------------------------------------------------
$Response = New-Object System.Data.DataTable
[void]$Response.Columns.Add("Key", "System.String")
[void]$Response.Columns.Add("Value", "System.String")
[void]$Response.Columns.Add("Data", "System.Data.DataTable")

#-Init Partners Data Table------------------------------------------
$PartnersTable = New-Object System.Data.DataTable

#-Create A Dummy Row------------------------------------------------
[void]$PartnersTable.Rows.Add("Test1", "Test2")

#-Add Partners Data Table To Response-------------------------------
[void]$Response.Rows.Add("PartnersTable", "", $PartnersTable)

#-Return Response---------------------------------------------------
Return $Response

After running the code in UiPath I am able to get the “Response” and even view it in the “Immediate” tab, but trying to work with the DataTable any further results in a “Late Binding” error.

I can view the “PartnersTable”

But trying to access any of it’s elements results in the error

Any help is appreciated, I would prefer not to change the method of getting a Response unless it nets the same result. The main reason for this is since for some scripts I need multiple nested DataTables as an Output.

1 Like

A potential solution I found is to export the DataTable as a CSV file and then read it within UiPath, as a plan B this looks like a good enough solution, but if possible I would like to find something that is a lot more elegant and can be achieved without creating external files.

#-Export Data Table As CSV------------------------------------------
$PartnersTable | Export-Csv C:\Users\dregv\table.csv -NoType