PS Hash Tables add Data in random position

Welcome Forums General PowerShell Q&A PS Hash Tables add Data in random position

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 6 months ago.

  • Author
    Posts
  • #26414

    Participant
    Points: 0
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    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.
    Cheers

  • #26417

    Participant
    Points: 0
    Rank: Member

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

The topic ‘PS Hash Tables add Data in random position’ is closed to new replies.