0

Unfortunately none of the referred answers are remotely solving the issue. Most of the solutions are either generic and do not apply or too specific to their related issues.

I have the output of 7-zip app, when I calculate hashcode of a given folder: ."$env:ProgramFiles\7-Zip\7z.exe" h C:\temp\ | select -skiplast 10 -skip 6

CRC32             Size  Name
-------- -------------  ------------
                        Temp\
54D2639E          1274  Temp\.log
                        Temp\CC\
362CADDA         15360  Temp\CC\install.log
7D41A917         19204  Temp\exitCode7.zip
63EB42A5       1003850  Temp\master.hash.txt

I want to parse that into powershell array of hashtables

$(
  ${CRC32='value', Size='value', Name='value' },
   ...
)
7
  • 2
    do you have control over the code exporting this data? Commented May 14, 2024 at 20:01
  • 2
    Welcome to SO, Deian. Please read the information at stackoverflow.com/help to learn how SO works. Please make special note of the need for the question to contain an MRE (Minimal, Reproducible Example) as well as a description of what does happen and what should happen. Without the code you are trying to make work, the question may attract downvotes and votes to close. Commented May 14, 2024 at 20:39
  • 2
    Have a look at the answers to this question - there’s 2 different answers that show ways to parse fixed-width tabular text (disclaimer - one is mine :-)) - stackoverflow.com/questions/66779538/… Commented May 14, 2024 at 23:05
  • 1
    If you looking for an of-the-shelf solution, you might try this ConvertFrom-SourceTable cmdlet. For examples, see: stackoverflow.com/search?q=%22ConvertFrom-SourceTable%22 Commented May 15, 2024 at 6:15
  • 1
    Deain: @iRon's impressive ConvertFrom-SourceTable script (which you can install with, e.g., Install-Script ConvertFrom-SourceTable -Scope CurrentUser or, in PowerShell 7, with Install-PSResource ConvertFrom-SourceTable -Scope CurrentUser) can handle your data format by default (no parameters needed) and it is a good command to have installed in general, as it is quite versatile. If you still want to roll your own solution: this answer to the first duplicate now works with your data format too. Commented May 15, 2024 at 20:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.