Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1154
  • Last Modified:

output Arrays with headers....

Hi,
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?

Thanks
0
Neil Russell
Asked:
Neil Russell
  • 2
  • 2
2 Solutions
 
soostibiCommented:
I can not see your loops. I can only see { as your second code, and also the 5th and 6th code just a part.
0
 
Neil RussellTechnical Development LeadAuthor Commented:
This is not a whole code listing, its the concept.  But easy enough to see the principal surely?
0
 
soostibiCommented:
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.
0
 
Neil RussellTechnical Development LeadAuthor Commented:
Thanks for tha
0
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.

Join & Write a Comment

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now