Posted by: Colin Smith
Since I started my new job, I let the guys that I used to work with know that I would be happy to help them out if they have any questions about anything especially powershell since I took care of pretty much all of our Powershell needs. And the other day I got an email asking about how to find out how many lines were in an array that they created doing a get-content on a file.They were doing:
$var | measure-object
This will get you what you want but it does not just give you the value. It will output more information then they were looking for. They also tried:
$var| measure-object | select-object count
This will work as well but this will also give the header and they did not want that so the easiest way to do this is to do a get-member on var and see if it gives you what you want as a property on that object.
you will see a length property. so if you say $var.length that will tell you how many entries are in the array…
hope that helps