This will preserve the order in which you have supplied the values in the HasTable. This time you will notice that the order of properties in input and output is same:
Why are HashTables useful?
Since HashTables can store any kind of values including objects/arrays/HashTables etc., they are great for using within your scripts for providing an output, especially when you want to have some kind of hierarchical output. You can easily convert the HashTables into PSCustomObjects before writing them as output. I will show you two different ways of converting the HashTables into PSCustomObject which is a good way for passing the output to next command in the pipeline.
Note that starting with PS 4 you do not need to use [Ordered] with [PSCustomObject], as the sequence gets preserved already.
And there is a lot more to say about hashtables, of course ...
Have a question about something in this article?
You can receive help directly from the article author.
Sign up for a free trial to get started.
Comments (1)
Commented:
And there is a lot more to say about hashtables, of course ...