PS Hash Tables add Data in random position

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of CHARALABOS CHARALABOS 1 year, 4 months ago.

  • Author
  • #26414
    Profile photo of CHARALABOS

    Hello community

    I put data in a hash table (using add method) but the order is very important for my task.
    By getting the contents from the hash table the order changes.
    I'm wondering what I'm doing wrong and how I can get my data from the hashtable in the correct order.

    thank you all in advance!!!

  • #26416
    Profile photo of Flynn Bundy
    Flynn Bundy

    Hi Mate,

    If you are using PowerShell version 3.0 or later. you should be able to declare your hash table like this:

    $hash = [ordered]@{ }

    This should make the contents display as you laid them out in the script.

    Let me know how you go.

  • #26417
    Profile photo of CHARALABOS

    IT WORKED !!! thank you very much!!!

You must be logged in to reply to this topic.