Share via

find text string patterns as keyword, set as column headers

TB 21 Reputation points
2021-04-23T23:57:23.56+00:00

Hi,

I have a long list of server names and underneath it, are the software names. These two text patterns are keywords (Server Name: ABC, software name: aaa...etc)

It's in a text file like this:

Server Name: ABC
sw name: this
sw name: that
sw name: there
sw name: they
....and so on until the next Server Name. The software name items are short and many are long ones.

How do I read it using PS and set each
Server Name: ABC-----Server Name: DEF----and so on
sw name: this----------sw name here-----and so on
sw name: that----------sw name here-----and so on
sw name: there--------sw name here-----and so on
sw name: they---------sw name here-----and so on

It reads the Server Names and the software names for each server underneath it.

THe output format file from text file to column headers in csv format.

Is this doable or possible to do with PS?

Thanks for your help in advance,

Windows for business | Windows Server | User experience | PowerShell

2 answers

Sort by: Most helpful
  1. TB 21 Reputation points
    2021-04-24T20:55:46.27+00:00

    I would hope with the keywords like software names would make a difference :)

    Oh well, thanks for looking into it Andreas. Yeah, I will ask for a better file next time instead of a text file, but a CSV format. The file I inherited from a different team.

    Thanks again Andreas, good day to you sir.

    Was this answer helpful?


  2. Andreas Baumgarten 132.1K Reputation points MVP Volunteer Moderator
    2021-04-24T12:52:48.17+00:00

    Hi @TB ,

    same challenge like your question before ;-)
    The sw nameline are varying in numbers per Server Name? (my guess)

    If "yes" it's not easy ... like with your question before ;-)

    I would really recommend a different approach:
    Where do you get the text file from? I would recommend to change the export format from a long list to CSV. CSV is a standard format for data exchange and easier to handle/transform..
    https://en.wikipedia.org/wiki/Comma-separated_values

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.