Can you set an object’s DefaultDisplayPropertySet in a PowerShell v2 script?

Question:

Here is a blog post from Kirk Munro that explains how a script can set the DefaultDisplayPropertySet on its output objects:

Essential PowerShell: Define default properties for custom objects

His technique and example code doesn’t appear to work in PowerShell v2. (Note, I have PowerTab and PSCX installed–perhaps those could be interfering.)

Anyone know how to get this to work on PowerShell v2?


UPDATE:
Here’s the example from the blog post, which isn’t working for me (note, I’ve corrected the single quote characters):

The output should not be the same after adding DefaultDisplayPropertySet (i.e., it should only have Name, Property2, and Property4).

Answer:

Can you give an example of your non-working code? This should work perfectly in v2, if not, you’ve found a bug.

UPDATE:

(removed comments about quoting)

I’ve confirmed with the powershell team that this is indeed a regression (bug).

You can vote on the issue’s importance to you here:

https://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=487938

Thanks,

-Oisin
(powershell MVP)

Source:

Can you set an object’s DefaultDisplayPropertySet in a PowerShell v2 script? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply