Filtering Text-Based Command Output

by Feb 24, 2014

Comparison operators act like filters when applied to arrays. So any console command that outputs multiple text lines can be used with comparison operators.

This example will use netstat.exe to get only established network connections, then to get only established network connections to any server that has "stor" in its name, and then uses ipconfig to get the current IPv4 address:

The trick is to enclose the console command in @() which makes sure that the result is always an array.

Twitter This Tip! ReTweet this Tip!