VMware Cloud Community
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

output help

I am checking versions and out of date, not installed and wrote this little ditty up:

  1. #this gets the client and host versions of the vmware tool
  2. New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'Config.tools.ToolsVersion' -Force
  3. New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.ToolsVersionStatus'-Force
  4. $ServerListFile = ".\servers.txt"
  5. $ServerList = Get-Content $ServerListFile -ErrorAction SilentlyContinue
  6. $Result = @()
  7. ForEach($computername in $ServerList)
  8. {
  9. Get-VM -name $computername | Select Name, Version, ToolsVersion, ToolsVersionStatus|ft -auto
  10. }

This but the output is like this:

Name           Version ToolsVersion ToolsVersionStatus

----           ------- ------------ ------------------

server     v11        10282 guestToolsCurrent

Name           Version ToolsVersion ToolsVersionStatus

----           ------- ------------ ------------------

server2     v11        10282 guestToolsCurrent

Name           Version ToolsVersion ToolsVersionStatus

----           ------- ------------ ------------------

server     v11        10282 guestToolsCurrent

I'd really like:

Name      Version      ToolsVersion      ToolsVersionStatus

----           -------           ------------           ------------------

server1     v11            10282                guestToolsCurrent

server2    v11             10282                guestToolsCurrent

server3    v11             10282                guestToolsCurrent

ty!

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
IT_pilot
Expert
Expert
Jump to solution

$vmList = Get-Content C:\servers.txt -ErrorAction SilentlyContinue

Get-VM $vmList | select name, @{N=’Version’;E={$_.Version}}, @{N=’ToolsVersion’;E={$_.Extensiondata.Guest.ToolsVersion}}, @{N=’Tools’;E={$_.Guest.ToolsVersion}},@{N=’ToolsVersionStatus’;E={$_.Extensiondata.Guest.ToolsVersionStatus}} | Format-Table -AutoSize

http://it-pilot.ru

View solution in original post

Reply
0 Kudos
5 Replies
IT_pilot
Expert
Expert
Jump to solution

Get-VM| select name, @{N=’Version’;E={$_.Version}}, @{N=’ToolsVersion’;E={$_.Extensiondata.Guest.ToolsVersion}}, @{N=’ToolsVersionStatus’;E={$_.Extensiondata.Guest.ToolsVersionStatus}} |  Format-Table -AutoSize

or more extended version:

Get-VM| ?{$_.Extensiondata.Summary.Guest.ToolsVersionStatus -ne ‘guestToolsCurrent’} | select name, @{N=’Version’;E={$_.Version}}, @{N=’ToolsVersion’;E={$_.Extensiondata.Guest.ToolsVersion}}, @{N=’Tools’;E={$_.Guest.ToolsVersion}},@{N=’ToolsVersionStatus’;E={$_.Extensiondata.Guest.ToolsVersionStatus}} | Format-Table -AutoSize 

http://it-pilot.ru
Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

Thank you, and while this is really helpful, I need just a specific set of systems. I don't want to monkey with it afterward to get the systems I want (there is no commonality with the names) I would have to go through them and find them, copy them out, etc.
That's why I was using a server list. I guess the my main problem is using for-each, and that puts out individual returns.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

#this gets the client and host versions of the vmware tool

New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'Config.tools.ToolsVersion' -Force | Out-Null

New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.ToolsVersionStatus'-Force | Out-Null

$ServerListFile = ".\servers.txt"

$ServerList = Get-Content $ServerListFile -ErrorAction SilentlyContinue

$Result = @()

$report = ForEach($computername in $ServerList)

{

    Get-VM -name $computername | Select Name, Version, ToolsVersion, ToolsVersionStatus

}

$report | ft -AutoSize


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

IT_pilot
Expert
Expert
Jump to solution

$vmList = Get-Content C:\servers.txt -ErrorAction SilentlyContinue

Get-VM $vmList | select name, @{N=’Version’;E={$_.Version}}, @{N=’ToolsVersion’;E={$_.Extensiondata.Guest.ToolsVersion}}, @{N=’Tools’;E={$_.Guest.ToolsVersion}},@{N=’ToolsVersionStatus’;E={$_.Extensiondata.Guest.ToolsVersionStatus}} | Format-Table -AutoSize

http://it-pilot.ru
Reply
0 Kudos
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

Both of the responses work well. It is funny how many different ways there are to accomplish the same thing.

I wish I could mark them both as 'correct'.

Reply
0 Kudos