PowerShell String Manipulation of Formatted Text in Columns
Every now and then, I find myself needing to use a utility like plink in order to interface with a system, such as a switch or a chassis, during a script. If I'm just sending configuration commands (and am taking it on faith that they worked...), then it's nice and easy, but if I actually want to extract information from the device, then I've got a bit of a challenge, because those devices (via plink) are not going to give me back an object that PowerShell understands. For example, if I use get-vm in PowerShell, I will get back a vm object that has a bunch of properties, which I can easily access using dot notation. If I use plink to pull a brocade switch configuration, all I'm going to get back (from PowerShell's perspective) is a great big long string with lots of New Line characters, tabs and spaces. So, how do I extract data from a formatted text string, in order to more easily work with it in PowerShell? Well, there's a lot of different tricks availab...