PowerShell 5.0 introduces a wonderful new cmdlet called ConvertFrom-String. Don’t let the simple name deceive you though. There is some exceptionally complex math running behind the scenes here to do some truly wonderful things.
In fact, the code that gets executed inside this function is based upon the "FlashExtract" project completed by Microsoft Research. How much math? Well here is a portion of the algorithm that was published in their whitepaper.
Source: http://research.microsoft.com/en-us/um/people/sumitg/pubs/pldi14-flashextract.pdf
The idea here is to give us as administrators the ability to take some existing complex text data, intelligently analyze it and convert it into native PowerShell objects.
Technically we can already do this today using regular expressions. But coming up with the right combination of letters and characters to produce the intended results is no easy task. At least until now.
The idea here is that instead of trying to micro manage exactly character-by-character how you want to extract the data to get to the content you want, you instead simply ‘tell’ PowerShell want you want.
Specifically, you pass the ConvertFrom-String function a marked up template of the data that indicates which data is important.
It’s hard to understand in writing but will make a lot more sense once you see it in action. This is also when the "ah ha" moment comes and you realize the power this new cmdlet offers.
For our example, we’re going to take a look at the c:\windows\windowsupdate.log. This is a plain text log file that contains several columns: