Powershell: Returning data tables without rows in functions Powershell: Returning data tables without rows in functions powershell powershell

Powershell: Returning data tables without rows in functions


I think your problem will be solved by simply using the unary comma operator in front of the table you're returning:

return ,$table

Powershell does some interesting automatic unrolling of collections that implement IEnumerable. The comma operator will wrap your table in a single-object array, so when it gets automatically unrolled it will return back to the table. I don't know of a way to force Powershell to not do this.

Here is a reference to the operators.