PowerCLI Function to get the version of ESX(i) VMware Tools corresponds to (Get-VMToolsMapped)

PowerCLI Function to get the version of ESX(i) VMware Tools corresponds to (Get-VMToolsMapped)

# Content of mapping file as of 08/03/2012:
Function Get-VMToolsMapped() {
Get-VMToolsMapped -VM MYVMNAME
.EXAMPLE
PS F:\> Get-VMToolsMapped MYVMNAME
.EXAMPLE
PS F:\> Get-VM | Get-VMToolsMapped
.EXAMPLE
PS F:\> Get-Cluster "CLUSTERNAME" | Get-VM | Get-VMToolsMapped
.LINK
.NOTES
Created by: Sean Duffy
Date: 08/03/2012
#>
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$true,HelpMessage="Specify the VM name you would like to query VMware Tools info for.",
ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[String]
$VM
)
process {
$Report = @()
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'config.tools.ToolsVersion' -Force
$VMInfo = Get-VM $VM | Select Name, ToolsVersion
Switch ($VMInfo.ToolsVersion) {
    8389 {$ESXMapping = "esx/5.0u1"}
    8384 {$ESXMapping = "esx/5.0"}
    8300 {$ESXMapping = "esx/4.1u2"}
    8295 {$ESXMapping = "esx/4.1u1"}
    8290 {$ESXMapping = "esx/4.1"}
    8289 {$ESXMapping = "esx/4.1"}
    8288 {$ESXMapping = "esx/4.1"}
    8196 {$ESXMapping = "esx/4.0u4 or esx/4.0u3"}
    8195 {$ESXMapping = "esx/4.0u2"}
    8194 {$ESXMapping = "esx/4.0u1"}
    8193 {$ESXMapping = "esx/4.0"}
    7304 {$ESXMapping = "esx/3.5u5"}
    7303 {$ESXMapping = "esx/3.5u4"}
    7302 {$ESXMapping = "esx/3.5u3"}
    default {$ESXMapping = "Unknown"}
    }
$row = New-Object -Type PSObject -Property @{
        Name = $VMInfo.Name
        ToolsVersion = $VMInfo.ToolsVersion
        ESXMapping = $ESXMapping
    }
$Report += $row
return $Report
}
}
Version history
Revision #:
1 of 1
Last update:
‎03-09-2012 03:32 AM
Updated by: