PowerCLI

 View Only
  • 1.  Get-VMHost - How to obtain version information?

    Posted Mar 24, 2008 01:13 PM

    We're in the middle of our ESX 3.0 -> 3.5 conversion and I was hoping to whip up a script to quickly display our list of hosts with their version/build info. I can't find a way to get at the version/build information. Does anyone know if this can be done with the current beta Toolkit? Thanks.



  • 2.  RE: Get-VMHost - How to obtain version information?
    Best Answer

    Posted Mar 24, 2008 01:32 PM

    Via the AboutInfo object.

    $fld = new-object System.Collections.Specialized.NameValueCollection

    $fld.Add("name", "")

    $tfld = find-entityview -viewtype HostSystem -filter $fld

    $tfld.Config.Product.Version

    $tfld.Config.Product.Build

    For the other fields in the object see http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/vim.AboutInfo.html



  • 3.  RE: Get-VMHost - How to obtain version information?

    Posted Mar 24, 2008 01:44 PM

    Thanks. Completely over my head. But it works. :smileywink:

    Seems like it would be a lot easier to get at this information from Get-VMHost directly.



  • 4.  RE: Get-VMHost - How to obtain version information?

    Posted Mar 24, 2008 01:51 PM

    For the nitty-gritty of this have a look at Carter's post called "How To: Accessing the entire Virtual Infrastructure API from PowerShell"



  • 5.  RE: Get-VMHost - How to obtain version information?

    Posted Mar 24, 2008 01:58 PM

    I agree, these items should be easier to get. But here is an easier way to do it:

    Get-VMHost | % { (Get-View $_.ID).Config.Product }

    P.S. Now that the Get-View(s) & Find-EntityView(s) cmdlets have been collapsed into the same snapin as the others, and they share the same server connection, you can use the ID property which exists on EVERY VI object as a reference. Saves much work.

    Hal Rottenberg

    Co-Host, PowerScripting Podcast (http://powerscripting.net)



  • 6.  RE: Get-VMHost - How to obtain version information?

    Posted Mar 24, 2008 02:24 PM

    Here's how to get the hostname in there:

    $FullName = @{ Label = "Product Full Name"; Expression = { (Get-View $_.ID).Config.Product.fullname } }
    Get-VMHost | ft name,$fullname
    
    Name                                       Product Full Name
    ----                                       -----------------
    host1.domain.com                       VMware ESX Server 3.5.0 build-64607
    host2.domain.com                       VMware ESX Server 3.0.2 build-52542
    host3.domain.com                       VMware ESX Server 3.0.2 build-52542

    Hal Rottenberg

    Co-Host, PowerScripting Podcast (http://powerscripting.net)



  • 7.  RE: Get-VMHost - How to obtain version information?

    Posted Mar 24, 2008 02:28 PM

    Beautiful. Exactly what I was looking for. Thanks to both Hal and Luc.

    BTW, I changed the last line to sort the hosts by name:

    Get-VMHost | Sort-object name | ft name,$fullname



  • 8.  RE: Get-VMHost - How to obtain version information?

    Posted Jun 03, 2009 02:44 AM

    Hi Hal

    How would you pipe this to an hml file.

    Here's my code:

    #HTML format

    $a = "<style>"

    $a = $a + "BODY{background-color:peachpuff;}"

    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"

    $a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"

    $a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"

    $a = $a + "</style>"

    $FullName = @{ Label = "Product Full Name"; Expression = { (Get-View $_.ID).Config.Product.fullname } }

    Get-VMHost | Sort-object name | ft name,$fullname | ConvertTo-Html -head $a -body "<H2>VMHosts</H2>" | Out-File d:\buildinfo.htm

    All I get in the htm file is the header and jibberish.

    Thanks

    Tony