RSS .92| RSS 2.0| ATOM 0.3
  • Home
  •  

    PowerCLI – Get VMware-Tools versions

    Imagine this:

    You are sitting in your cube on a Tuesday morning and your boss walks in and says: “I need all of the installed versions of VMware-Tools to report for compliance!”  Your initially reaction is probably: “really?”  And then you say, OK, I can do that.

    And here is how to do it:

    # Add in the VI Toolkit goodness
    if ( (Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null )
    {
    Add-PSsnapin VMware.VimAutomation.Core
    }
    
    # Connect to the vCenter server(s)
    $vcserver= @()
    
    $vcserver += connect-VIServer "<Your vCenter Server>"
    
    # get the vmware tools version for each VM
    
    get-vm |% { get-view $_.id } | select Name, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}}
    
    # Disconnect from the vCenter server(s)
    disconnect-viserver $vcserver -Confirm:$False
    
    # END
    ###
    
    

     

    Your output will be of the form:

    server1.example.com   200000

    server2.example.com   0

    etc.

    Update (3/25/2011): My colleagues found a post on the VMTN page that has to do with my script.  LucD had another idea on how to run the script that would generate so much load on vCenter.  Check it out here.

    3 responses to “PowerCLI – Get VMware-Tools versions”

    1. Hello,

      The get-vm is not needed in the script, simply used this command :

      Get-View -ViewType VirtualMachine | select Name, @{ Name=”ToolsVersion”; Expression={$_.config.tools.toolsVersion}}

      It will be faster 😉

      • My code snippet was actually embedded in a loop to only walk through certain clusters, so I don’t believe get-view would have worked in my original use-case. I could be wrong though. However, if you are trying to walk through all VM’s in vCenter, I do believe your snippet would indeed beat mine in speed!

        Good to note. Thanks!
        PD

    Leave a Reply

    Your email address will not be published. Required fields are marked *