Powershell beginner


I’m just an infant in the world of Powershell. Thought it was just something that loaded up with Windows.

Anyway, I don’t know where to begin but I need to see if powershell can help me interrogate some data files. I’ve previously used basic DOS commands but probably need something with a little more guts now.

I deal with *. Flt data files, repeating data lines.

I would like to know if it is possible to define.

When line begins with ‘150’ for instance bring me back byte references 60-80.
I’d want it to search the whole data file and return the hits in a text file.

Any pointers or comments to say, yes powershell can do this, or no you need something else…

Many thanks in advance.

Yes, Powershell can do what you are asking.

  • Find all of the *.flt files - Get-ChildItem (alias is DIR in DOS)
  • Open the file - Get-Content or if it’s in a delimited format, then you can use Import-Csv
  • foreach line in file, Get-Content returns an array of lines, so you need to loop through them
  • Find what starts with 150, this can be a where clause or REGEX depending on what you getting. Split-String, -match or even -like operators can find the rows that start with 150.

The best way to learn is to read the help on the above, look at examples on blogs and forums and if you get stuck ask questions. If you need help with parsing data, please post examples of your code and the data cleansed.

Thanks Rob, good to know I won’t be wasting time reviewing powershell capabilities.

I’ll get my reading hat on and have a play!!