hepl with PS output.

I have a small script that  uses powercli to get some info (tool version) and it works just fine. The output is messy. Here is the script:
#this gets the client and host versions of the vmware tool
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'Config.tools.ToolsVersion' -Force
New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.ToolsVersionStatus'-Force
$ServerListFile = ".\servers.txt" 
$ServerList = Get-Content $ServerListFile -ErrorAction SilentlyContinue
$Result = @()
ForEach($computername in $ServerList)
{
Get-VM -name $computername | Select Name, Version, ToolsVersion, ToolsVersionStatus|ft -auto
}

Open in new window


The output looks like this:
Name           Version ToolsVersion ToolsVersionStatus
----           ------- ------------ ------------------
server     v11        10282 guestToolsCurrent

Name           Version ToolsVersion ToolsVersionStatus
----           ------- ------------ ------------------
server2     v11        10282 guestToolsCurrent

Name           Version ToolsVersion ToolsVersionStatus
----           ------- ------------ ------------------
server3     v11        10282 guestToolsCurrent

Open in new window


I'd like it to be :
Name        Version ToolsVersion ToolsVersionStatus
----              -------      ------------         ------------------
server1     v11        10282              guestToolsCurrent
server2     v11        10282              guestToolsCurrent
server3     v11        10282              guestToolsCurrent

[

Open in new window


The formatting in this post isn't what I'd like, but I think you see what I mean.

thx!!
~Jahn
LVL 3
SquigglyMonkeyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
You're sending single formatted object to the pipeline.
Try it like this:
#this gets the client and host versions of the vmware tool
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'Config.tools.ToolsVersion' -Force
New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.ToolsVersionStatus'-Force
$ServerListFile = ".\servers.txt" 
$ServerList = Get-Content -Path $ServerListFile -ErrorAction SilentlyContinue
$ServerList | ForEach-Object {
	Get-VM -Name $_ | Select Name, Version, ToolsVersion, ToolsVersionStatus
} | Format-Table -AutoSize

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SquigglyMonkeyAuthor Commented:
Thank you that works perfectly.
0
SquigglyMonkeyAuthor Commented:
adding this seems to be the main thing.
$Result = @()
1
Senior IT System EngineerIT ProfessionalCommented:
So where do you add the $Result = @() ?
0
SquigglyMonkeyAuthor Commented:
I was having a rough day, and wrote that incorrectly.
What I should have written was removing $Result = @() and then piping $serverlist into foreach-object

$Result = @()
ForEach($computername in $ServerList)

Open in new window

became
$ServerList | ForEach-Object 

Open in new window


Very sorry about the confusion.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.