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:
The output looks like this:
I'd like it to be :
The formatting in this post isn't what I'd like, but I think you see what I mean.
thx!!
~Jahn
#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
}
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
I'd like it to be :
Name Version ToolsVersion ToolsVersionStatus
---- ------- ------------ ------------------
server1 v11 10282 guestToolsCurrent
server2 v11 10282 guestToolsCurrent
server3 v11 10282 guestToolsCurrent
[
The formatting in this post isn't what I'd like, but I think you see what I mean.
thx!!
~Jahn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
adding this seems to be the main thing.
$Result = @()
$Result = @()
So where do you add the $Result = @() ?
ASKER
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
Very sorry about the confusion.
What I should have written was removing $Result = @() and then piping $serverlist into foreach-object
$Result = @()
ForEach($computername in $ServerList)
became $ServerList | ForEach-Object
Very sorry about the confusion.
ASKER