read file line as hashtable

Welcome Forums General PowerShell Q&A read file line as hashtable

Viewing 2 reply threads
  • Author
    Posts
    • #189949
      Participant
      Topics: 13
      Replies: 21
      Points: 204
      Rank: Participant

      hi all,

      another noob question, please

      I have a list of files I have to check if some value is present. Each line on these files are in a format like;

      Name1=nameHere Value=

      Name2=nameHere Value=someValue

      Value could be either empty or not.

      my question is: how can I read each line and place it in a hashtable, so then I can do if ($hash.Value -ne ") ...

      thank you!

    • #189958
      Participant
      Topics: 2
      Replies: 510
      Points: 1,301
      Helping Hand
      Rank: Community Hero

      You could use a bit of regex parsing on each line, I suppose.

      But it will depend a lot on the format of your file and how consistent it is.

    • #189973
      Participant
      Topics: 13
      Replies: 21
      Points: 204
      Rank: Participant

      it's perfect.

      thanks!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.