output Arrays with headers....

Posted on 2010-09-13
Last Modified: 2012-08-13
hopefully a simple question with a simple answer....

I Initialise an array, No problems,
$Global:myData = @()

Open in new window

I have an array populated in a loop, no problems.

Open in new window

I add to the array in an inside loop, again no problems
$myUser = Get-QADUser $username | Select Name, Email
$Global:myData += $myUser

Open in new window

I output the array contents, no problem FIRST time through but read on....
$myData | Sort Name | Select Name, Email -Unique

Open in new window

I reinitialise the array and loop back to next itteration...
$Global:myData = @()

Open in new window

Now on the FIRST run through the loop i get output with column names of Name and  Email nicely underlined with the array data below listed nicely. On subsequent iterations of the loop, no column headings show?

How do i force it to show these headers with eacho output of $myData?

Question by:Neil Russell
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 13

Assisted Solution

soostibi earned 500 total points
ID: 33668710
I can not see your loops. I can only see { as your second code, and also the 5th and 6th code just a part.
LVL 37

Author Comment

by:Neil Russell
ID: 33742006
This is not a whole code listing, its the concept.  But easy enough to see the principal surely?
LVL 13

Accepted Solution

soostibi earned 500 total points
ID: 33742550
Actually the items probably include the properties, just the formatting on the console is problematic. In this case I suggest to use the
| format-table name, email
at the very end of your expression.
LVL 37

Author Closing Comment

by:Neil Russell
ID: 33839194
Thanks for tha

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question