Ordered Hash Tables in Windows PowerShell V3.

Ordered Hash Tables in Windows PowerShell V3.
Generally When we work with Hash Tables in PowerShell we usually get an output as an unordered data and not as ordered as per our liking.For example if i create a new hash table as below

PS C:UsersAdministrator> @{Name='Vinith';City='Bangalore';Skill='PowerShell'}

And see its output it would turn out like something below and i do see that the output order was jumbled up and it was not as per our initialization

In New PowerShell V3 we get a new attribute called as ordered which allows us to order up the information present in a Hash Table.

Now if i run the same command with an [ordered] attribute in front of it i can indeed see that the data turned out to be in ordered form.

PS C:UsersAdministrator> [ordered] @{Name='Vinith';City='Bangalore';Skill='PowerShell'}

 

 

Share this post

Post Comment