{"id":454,"date":"2013-06-14T17:47:38","date_gmt":"2013-06-14T07:47:38","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=454"},"modified":"2014-03-08T14:47:03","modified_gmt":"2014-03-08T03:47:03","slug":"speed-comparison-counting-esx-versions","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=454","title":{"rendered":"Speed Comparison &#8211; Counting ESX Versions"},"content":{"rendered":"<p>In this Speed Comparison I am reporting on the number of each ESX version I have in my environment to generate a report like the one below.<\/p>\n<figure id=\"attachment_455\" aria-describedby=\"caption-attachment-455\" style=\"width: 184px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/threemillion.net\/blog\/wp-content\/uploads\/2013\/06\/SS_ESXiVersions.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-455 \" alt=\"Table displaying the ESX Versions and how many hosts of that version.\" src=\"https:\/\/threemillion.net\/blog\/wp-content\/uploads\/2013\/06\/SS_ESXiVersions.png\" width=\"184\" height=\"212\" \/><\/a><figcaption id=\"caption-attachment-455\" class=\"wp-caption-text\">Table displaying the ESX Versions and how many hosts of that version.<\/figcaption><\/figure>\n<p>This table is not really a good example of a standardised environment I admit. However this is the reality of the real world large enterprise.<\/p>\n<p>These timing tests were run against a vCenter with\u00a0 three (3) clusters of eight (8) hosts.<\/p>\n<h1>Old Way<\/h1>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n#Get list of all the esx hosts\r\n$vmhostlist = Get-VMHost\r\n#Create ESXi Version count report\r\n$esxiversions = $vmhostlist | ? { $_.Extensiondata.Config.Product.ProductLineId -eq \"embeddedEsx\" } | Select Name, Version, Build | Group Build | Select Count, @{Name=\"Version\"; Expression={$_.Group[0].Version} }, @{Name=\"Build\"; Expression={$_.Name} }  | Sort-Object Build -Descending\r\n<\/pre>\n<h3><strong>Timings<\/strong><\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nTask          : Seconds\r\n$vmhostlist   :   6.3\r\n$esxiversions :  35.4\r\n<\/pre>\n<h1>New Way<\/h1>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n#Define variable script blocks for Select-Object\r\n$esxtype = @{Name=\"ESX\"; Expression={$_.Config.Product.ProductLineId} }\r\n$version = @{Name=\"Version\"; Expression={$_.Config.Product.Version} }\r\n$build = @{Name=\"Build\"; Expression={$_.Config.Product.Build} }\r\n\r\n#Get list of all the esx hosts\r\n$vmhostlist = Get-View -ViewType HostSystem -Property Name, Config.Product.ProductLineId, Config.Product.Version, Config.Product.Build -Filter @{\"Config.Product.ProductLineId\"=\"embeddedEsx\"}\r\n\r\n#Create ESXi Version count report\r\n$esxiversions = $vmhostlist | Select Name, $esxtype, $version, $build | Group Build | Select Count, @{Name=\"Version\"; Expression={$_.Group[0].Version} }, @{Name=\"Build\"; Expression={$_.Name} }  | Sort-Object Version -Descending\r\n<\/pre>\n<h3><strong>Timings<\/strong><\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nTask          : Seconds\r\n$vmhostlist   :   3.7\r\n$esxiversions :   0.008\r\n<\/pre>\n<h1>Production Results<\/h1>\n<p>These are the core components of a reporting script that runs against my entire environment. 950+ ESXi Hosts. Using the old way this report takes 16.5 minutes. Using the new way 27 seconds.<\/p>\n<p>Whilst this approach does make the script a little more convoluted, it clearly demonstrates the power of refining your search criteria to just the information required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this Speed Comparison I am reporting on the number of each ESX version I have in my environment to generate a report like the one below. This table is <a href=\"https:\/\/threemillion.net\/blog\/?p=454\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[49],"tags":[55],"class_list":["entry","author-admin","post-454","post","type-post","status-publish","format-standard","category-powercli","tag-get-view"],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=454"}],"version-history":[{"count":9,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/454\/revisions"}],"predecessor-version":[{"id":478,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/454\/revisions\/478"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}