Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8435981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:04:20+00:00 2026-06-10T07:04:20+00:00

I have a custom CmdLet written in C# which returns an array of objects.

  • 0

I have a custom CmdLet written in C# which returns an array of objects. For testing purposes, they’re anonymous.

    protected override void ProcessRecord()
    {
        var anonType1 = new { name = "Mikey", description = "Brown" };
        var anonType2 = new { name = "Davo", description = "Green" };

        List<object> stuff = new List<object>();
        stuff.Add(anonType1);
        stuff.Add(anonType2);

        this.WriteObject(stuff.ToArray());
    }

This gives the following output in PS2:

name       description
----       -----------
Mikey      Brown
Davo       Green

If I use Select-Object name I would hope to just exclude the ‘description’ property and get Mikey and Davo stacked on top of each other, but no! I get:

name
----

Where’s my data!?

Thanks

Luke

As a side: does anyone know of a good learning resource for programming CmdLets and working with the internals of PS (rather than PS usage which most books are about)? Ta

UPDATE

Even if I make strong types, new a few up and put them in a PSDataCollection it doesn’t work as I expect. My expectations are clearly wrong. How do I correctly output collections of data to the pipeline??

SOLVED

We have to set enumerateCollection = true. Sounds stupid but we weren’t using the WriteObject protected method but our own WriteToAvailableOutput which diverts to the debugger from within Visual Studio! So we could not see the extra overload on WriteObject – dhuurr!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:04:21+00:00Added an answer on June 10, 2026 at 7:04 am

    The answer it to use the WriteObject overload with the enumerateCollection parameter set to true.

    this.WriteObject(stuff.ToArray(), true);
    

    Stupid me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom db class which extends MySQLi class MySQLi->query() method returns obejct with
I have custom Question objects which I render into html form elements. I want
I have a custom cmdlet that can be called like this: Get-Info .\somefile.txt My
I have developed a custom c# cmdlet. It has three parameters (all of them
I have custom SiteMapProvider and RoleProvider that works together properly: IsAccessibleToUser returns false if
I have custom cell which contains number of rows in it.i want to write
I have custom js/jquery code which is running fine on all browsers including IE9
I have written a custom scaffolder for MVC3 using T4 templates to scaffold a
I have custom control written in Java. For the sake of simplicity lets assume
I have custom groupViews that need to change state when they are expanded and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.