How do you count lines in a file or from output of a command?
On Linux, it is easy: just use wc -l
but how to do it with PowerShell?
This is how:
(ls | Measure-Object -line).Lines
For example count number of active TCP connections
(netstat -na | Select-String ESTABLISHED | Measure-Object -line).Lines