{"id":449,"date":"2013-05-31T09:13:22","date_gmt":"2013-05-30T23:13:22","guid":{"rendered":"http:\/\/threemillion.net\/blog\/?p=449"},"modified":"2013-05-31T09:13:22","modified_gmt":"2013-05-30T23:13:22","slug":"speed-comparison-vmhost-models","status":"publish","type":"post","link":"https:\/\/threemillion.net\/blog\/?p=449","title":{"rendered":"Speed Comparison &#8211; VMHost Models"},"content":{"rendered":"<p>You may know by now that in PowerCLI there are a couple of ways to get information such as ESX host details using predefined cmdlets such as:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$vmhost = Get-VMHost\r\n<\/pre>\n<p>There is also another way using the Get-View cmdlet<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$vmhost = Get-View -ViewType HostSystem\r\n<\/pre>\n<p>Depending on the information you require and the size of your environment the time these commands take to run could be siginificant.<br \/>\nTimings in seconds:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nGet-VMHost : 33.5733573\r\nGet-View\u00a0\u00a0 : Exception of type 'System.OutOfMemoryException' was thrown.\r\n<\/pre>\n<p>Or in the case of my Production environment error out due to lack of memory in the Powershell. <strong>Note to self:<\/strong> Find out how to increase the memory space.<\/p>\n<p>Get-VMHost gets a subset of all available information. Get-View gets a larger amount of data.<br \/>\nFor the purposes of my current task I only want information on a particular Model of host. In this case I am only interested in HP DL380 servers.<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$vmhost = Get-VMHost | ? { $_.Model -match &quot;ProLiant DL380&quot; }\r\n$vmhost = Get-View -ViewType HostSystem -Filter @{&quot;Hardware.SystemInfo.Model&quot;=&quot;ProLiant DL380&quot;}\r\n<\/pre>\n<p>Timings in seconds:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nGet-VMHost : 35.5198533\r\nGet-View\u00a0\u00a0 :\u00a0 8.6454952\r\n<\/pre>\n<p>So why do I care about Get-View vs Get-VMHost?<\/p>\n<p>For the most part I use PowerCLI to do reporting. As I have a large number of reporting scripts and I am only retrieving information, almost all the information I am after I can retrieve via Get-View.<br \/>\nIn the above example above I have saved 27 seconds in just one command. With a large number of commands in my reporting scripts these precious seconds add up to significant time savings. More importantly by refining the information requested, the load on the vCenter servers is reduced.<\/p>\n<p>I am only at the start of my Get-View journey. Most of my current scripts need to be re-written as some are many years old now and are a historical recording of my learning process in Powershell and PowerCLI. So over time it will be very interesting to convert all of these scripts and see the total time changes I can affect.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may know by now that in PowerCLI there are a couple of ways to get information such as ESX host details using predefined cmdlets such as: There is also <a href=\"https:\/\/threemillion.net\/blog\/?p=449\" 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":[],"class_list":["entry","author-admin","post-449","post","type-post","status-publish","format-standard","category-powercli"],"_links":{"self":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/449","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=449"}],"version-history":[{"count":3,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/449\/revisions"}],"predecessor-version":[{"id":452,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/449\/revisions\/452"}],"wp:attachment":[{"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/threemillion.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}