Tag Archives: ordered objects

24Jan/18

PowerShell: Control What Order Properties Are Displayed On A Custom Objects And Hash Tables

There are a handful of different ways to create custom objects in PowerShell, including building one from a hash table. You might do something like this.

But then, just runĀ $obj and see what you get. This is what I got.

It put prop2 before prop1 even though I put prop1 first in the hash table! Most of the time, this doesn’t matter, but what about when it does?

Continue reading