I am checking versions and out of date, not installed and wrote this little ditty up:
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!
$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
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
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.
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
$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
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'.
