Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Pattern matching for a text file?

$
0
0

I have a text file with UEFI configuration data.  For the vendor, this is the only way to interact and write settings, such as the asset tag, which is what I"m trying to write.

In vbscript, I'd just walk the text file until I found "Asset Tracking Number", then look at the very next line.  In some cases this will be empty.  If there is data there, it will have a tab, then the asset tag information.  This format is mandatory.

I need to understand how to get this data with powershell, as I'm writing a .Net windows forms interface (the very long way, by hand...) so our help desk folks can read and modify the settings in the UEFI that can be edited without having to resort to editing the text file directly and then running the command line to import the file (the interaction directly with the text file, the better).

I get the whole pattern matching thing - what I don't understand is how to get pairs of values, particularly if one of them may be absent...

The second part is I need to write the data back to the text file.  In vbscript, again, I would just create a new text file and write all the values back into it, adding the new data, and keep the old text file as a backup.

Any help, even a RTFM with a website reference that has the info, would be appreciated.  I'm coming up empty on my searches and can't seem to find the "Magic words".


Viewing all articles
Browse latest Browse all 6937

Trending Articles