Question : Remove header from array created using Get-QADComputer cmdlet?

Ok,

So I'm generating a list of servers using:

$ServerList = (Get-QADComputer -OSName 'Windows*Server*' | Select-Object name )

What's happening, is that when I type $ServerList, I get this output:

Name
----
<Server1>
<Server2>
<Server3>
...etc.

Whenever I attempt to use the $ServerList array object, the first element ALWAYS indcludes:

"Name
----"

Which causes me to loose the first server in the list as it's programatically not useful.

How do I eliminate the "Name ----" that is always inserted whenever I use the $ServerList array?

This has got to be super noobish...  But I'm at a loss...

Answer : Remove header from array created using Get-QADComputer cmdlet?


You're mis-understanding the display.

Name is not part of the array, it's there because your output is formatted. It's adding the header becase Name is the only property in your array of objects.

Consider the output from this:

$ServerList | ForEach-Object { $_.Name }

Notice now that you have no header, there's no reason for this other than you're removing the objects and changing it into an array of strings.

None of this will have an impact on the Excel sheet you're generating.

Chris
Random Solutions  
 
programming4us programming4us