Walkthrough – Parsing log or console output with PowerShell


As I go from project to project, inevitably a question like this one arises:

Stephen, I know I COULD do this by hand, but surely PowerShell can do it for me!  Help!

In this post I’ll walk you through a real world example of how to parse the output of a non-PowerShell command and convert it into PowerShell objects we can work with to export reports, run SQL queries, or to do literally anything under the sun.

If you’ve ever needed to parse log or batch file command output and have slaved at it, hopefully this approach makes things a little easier for you.

This is part of a two-part series,  in this post we’ll go step-by-step through the traditional, tried-and-true method of parsing output.  The next post in the series is all about using Convert-FromString to parse input instead, a powerful new addition to PowerShell in version 5.0.

Continue reading