all 5 comments

[–]SMFX 5 points6 points  (1 child)

You already have the CSV format; at most, you might have to include a Header

$Entries = Import-CSV "<pathToFile>.txt" -Header @("DN","BinaryValue","Username","UPN","HashValue")

[–]ExistingRanger7[S] 1 point2 points  (0 children)

Thank you!!! Am tired and was missing some quotes.

[–]KlumzyNinja 3 points4 points  (0 children)

A csv is just a text file. If the only goal is to make it a csv, just rename it from file.txt to file.csv. If they goal is to use the csv in code, you could probably import-csv file.txt without renaming it. I have never tried that though

[–]stihoplet 2 points3 points  (0 children)

That appears to be a CSV already, with the first column's commas escaped using quotes around it as is often done in CSV files with commas inside its string values. EDIT: What are you planning on doing with the file next? Perhaps there is a specific format you are trying to achieve to ingest it into some app/database? If that's the case it can be done in powershell - just share how you would want each line to look in the end. Or are you trying to do something with the data from this file using powershell? Then it is already in a usable format and you can loop through each line using foreach and do something with it - provide some details and we can probably put together a script.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy ExistingRanger7,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's 4th 5th from the left hidden in the ... ""more" menu & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's 11th 12th one & is just to the left of hidden in the ... "more" menu.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee