Link to home
Start Free TrialLog in
Avatar of SquigglyMonkey
SquigglyMonkey

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SquigglyMonkey
SquigglyMonkey

ASKER

Thank you that works perfectly.
adding this seems to be the main thing.
$Result = @()
So where do you add the $Result = @() ?
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.