#Description: This function checks for VMs with out-of-date VMware tools
#Purpose: Discovering VMs that require VMTools updated
#Designed to be added as function into $profile for quick-admin tasks, run from commandline
#Requires VCLI snapin - www.vmware.com/support/developer/vcli/
#Author: Kirk Munro, extracted from VMware powerpack: http://www.powergui.org/entry.jspa?externalID=1802&categoryID=290
#Tested with: ESX4.1
#Last edit by: MsMiller on 11/08/2011
function func_VMs_with_Out_of_Date_Tools()
{
$noConnection = $true
if ($defaultVIServers) {
foreach ($managedHost in $defaultVIServers) {
$noConnection = $false
Get-VM -Server $managedHost | Get-View | ForEach-Object {
if ($_.Guest.ToolsStatus -eq "ToolsOld"){
$_.PSObject.TypeNames.Insert(0,"$($_.PSObject.TypeNames[0])#VmwarePowerPackExtension")
$_ `
| Add-Member -MemberType NoteProperty -Name ToolsStatus -Value $_.Guest.ToolsStatus -PassThru `
| Add-Member -MemberType NoteProperty -Name ToolsVersion -Value $_.Guest.ToolsVersion -PassThru `
| Add-Member -MemberType NoteProperty -Name ManagedHost -Value $managedHost.Name -PassThru
}
}
}
}
if ($noConnection){
Show-MessageBox -Text 'You must connect to one or more vSphere servers before you can run the VMs with Out of Date Tools best practice query on those servers. Please click on the ''Managed Hosts'' node, connect to one or more of the vSphere servers you have configured there, and then try again.' -Caption 'Connection not established' -Buttons 'OK' -Icon 'Information' | Out-Null
}
}
func_VMs_with_Out_of_Date_Tools | Select-Object -property 'Name', 'ToolsStatus', 'ToolsVersion', 'ManagedHost'