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 $ } | select Name, @{ Name="ToolsVersion"; Expression={$}}
    # Disconnect from the vCenter server(s)
    disconnect-viserver $vcserver -Confirm:$False
    # END


    Your output will be of the form:   200000   0


    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={$}}

      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!

    Leave a Reply

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