The Multifunctioning DBA

Sep 27 2011   10:00AM GMT

Some Powershell Help

Colin Smith Colin Smith Profile: 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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: