7

Working on a simple helper function in PowerShell that takes a couple of parameters and creates a custom Enumerable object and outputs that object to the pipeline. The problem I am having is that PowerShell is always outputting a System.Array that contains the objects that are enumerated by my custom Enumerable object. How can I keep PowerShell from unpacking the Enumerable object?

The code: http://gist.github.com/387768

Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
  • 3
    PowerShell is sometimes too clever. Look at http://stackoverflow.com/questions/1918190/strange-behavior-in-powershell-function-returning-dataset-datatable – stej May 03 '10 at 09:38

1 Answers1

7

Try to change the line 46 from

$row

to

, $row

EDIT: as Johannes correctly pointed out, the unary operator comma creates an array with one member.

Roman Kuzmin
  • 40,627
  • 11
  • 95
  • 117
  • 4
    Explanation: This wraps whatever you want to return in an array (with just one element). This array will be unwrapped but its contents are not. – Joey May 03 '10 at 09:13