{"id":411,"date":"2014-08-07T08:16:49","date_gmt":"2014-08-07T07:16:49","guid":{"rendered":"http:\/\/virtualworlduk.co.uk\/?p=411"},"modified":"2014-08-07T08:16:49","modified_gmt":"2014-08-07T07:16:49","slug":"esxi-host-versions-powercli","status":"publish","type":"post","link":"https:\/\/www.virtualworlduk.co.uk\/wordp\/esxi-host-versions-powercli\/","title":{"rendered":"ESXi Host Versions &#8211; PowerCli"},"content":{"rendered":"<p>Okay, so I would admit that I&#8217;m not the best with PowerCli but recently we had a request to produce a list of all of the ESXi hosts we have on a vCenter along with their Version and build number.<\/p>\n<p>Now this can be done easily on an individual basis by logging onto each host and running the command:<\/p>\n<pre>vmware -vl<\/pre>\n<p>This will produce a result similar to below:<br \/>\n<a href=\"http:\/\/virtualworlduk.co.uk\/wp-content\/uploads\/2014\/08\/vmwarevl.jpg\"><img decoding=\"async\" class=\"alignleft size-full wp-image-412\" src=\"http:\/\/virtualworlduk.co.uk\/wp-content\/uploads\/2014\/08\/vmwarevl.jpg\" alt=\"vmwarevl\" width=\"263\" height=\"49\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Unfortunately performing this command on a number of hosts could be time consuming. \u00a0I therefore went ahead and produced the following PowerCli script that would collect it for a number of hosts on a vCenter&#8230; as previously explained, there may be a better way to perform this in PowerCli but this solution worked for me:<\/p>\n<pre>Connect-VIServer -Server <em>vCenterName\n\n<\/em>$style = \"&lt;style&gt;BODY{font-family: Arial; font-size: 10pt;}\"\n$style = $style + \"TABLE{border: 1px solid black; border-collapse: collapse;}\"\n$style = $style + \"TH{border: 1px solid black; background: #dddddd; padding: 5px; }\"\n$style = $style + \"TD{border: 1px solid black; padding: 5px; }\"\n$style = $style + \"&lt;\/style&gt;\"\n\n$smtpServer = \"<em>smtpservername<\/em>\"\n$smtpFrom = \"VMware Build Versions &lt;<em>senderemailaddress<\/em>&gt;\"\n$smtpTo = \"<em>destinationemailaddress<\/em>\"\n$messageSubject = \"VMware Build Versions - $(Get-Date)\"\n$message = New-Object System.Net.Mail.MailMessage $smtpfrom, $smtpto\n$message.Subject = $messageSubject\n$message.IsBodyHTML = $true\u00a0\n\n$dts = @(\nget-view -ViewType HostSystem -Property Name, Config.Product | select Name,@{ expression={$_.Config.Product.Version}; label='Version' },@{ expression={$_.Config.Product.Build}; label='Build Number' }\n)\n$message.Body = $dts | ConvertTo-HTML -Head $style\n\n$smtp = New-Object Net.Mail.SmtpClient($smtpServer)\n$smtp.Send($message)<\/pre>\n<p>This should produce an email with a table similar to below:<br \/>\n<a href=\"http:\/\/virtualworlduk.co.uk\/wp-content\/uploads\/2014\/08\/result.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignleft size-medium wp-image-414\" src=\"http:\/\/virtualworlduk.co.uk\/wp-content\/uploads\/2014\/08\/result-199x300.jpg\" alt=\"result\" width=\"199\" height=\"300\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay, so I would admit that I&#8217;m not the best with PowerCli but recently we had a request to produce a list of all of the ESXi hosts we have on a vCenter along with their Version and build number. Now this can be done easily on an individual basis by logging onto each host and running the command: vmware [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":451,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vmware"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":0,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtualworlduk.co.uk\/wordp\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}