Powershell. Find the number of columns in an array.

Powershell v1.
I'm writing a script that puts the contents of an array into an Excel workbook. The scripts needs to know how many columns and how many rows are in the array. The count property gives me the number of rows. How do I find out the number of columns in an aray?

Consider the following snippet:

If you type "$array.length", you get response "2" because there are 2 rows in the array. But suppose you want to know how many columns are in the array. You can see that there are are 5 columns. How do you programmatically get that number?
Who is Participating?

Try this

The reason is that you have an array that has two nested arrays...

Open in new window

HondoExpatAuthor Commented:
That works perfectly. Sometimes I wish PS was a little more intuitive.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.