{"id":97,"date":"2008-12-01T17:34:48","date_gmt":"2008-12-01T16:34:48","guid":{"rendered":"http:\/\/www.amikkelsen.com\/?p=97"},"modified":"2008-12-20T23:36:45","modified_gmt":"2008-12-20T22:36:45","slug":"bulk-upgrading-vms-memory","status":"publish","type":"post","link":"https:\/\/www.amikkelsen.com\/?p=97","title":{"rendered":"BULK upgrading VM&#8217;s memory"},"content":{"rendered":"<p>Today I had to upgrade all our Jumphost VM&#8217;s from 256MB to 512MB of memory (more than 200 <span style=\"font-family: Wingdings;\"><span>VM&#8217;s<\/span><\/span>).<br \/>\nThere are two ways accomplice this.<\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"margin-left: 20.25pt; text-indent: -18pt;\"><!--[if !supportLists]--><span><span>1.<span style=\"font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: \"> <\/span><\/span><\/span><!--[endif]--><span>Do it manually (Very time consuming)<\/span><\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin-left: 20.25pt; text-indent: -18pt;\"><!--[if !supportLists]--><span><span>2.<span style=\"font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: \"> <\/span><\/span><\/span><!--[endif]--><span>Script it with PowerShell<\/span><\/p>\n<p class=\"MsoNormal\"><span> <\/span><\/p>\n<p class=\"MsoNormal\"><span>As the lazy person I am I decided that scripting was the way forward.<br \/>\nThe script I came up with is as follows:<\/span>\n<\/p>\n<p class=\"MsoNormal\"><span> <\/span><\/p>\n<pre class=\"MsoNormal\" style=\"padding-left: 30px;\"><span lang=\"DA\">Connect-VIServer \"vi_servername\" -User \"vi_username\" -Password password\"\r\n\r\n<\/span><\/pre>\n<pre class=\"MsoNormal\" style=\"padding-left: 30px;\"><span># Select all VM's that have less than 512MB and change the Memory to 512MB<\/span><\/pre>\n<pre class=\"MsoNormal\" style=\"padding-left: 30px;\"><span>foreach ($vm in Get-VM | Select Name,MemoryMB | Where-Object{$_.MemoryMB -lt \"512\"}){<\/span><\/pre>\n<pre class=\"MsoNormal\" style=\"padding-left: 60px;\"><span>Set-VM $vm.Name -MemoryMB \"512\" -Confirm:$FALSE<\/span><\/pre>\n<pre class=\"MsoNormal\" style=\"padding-left: 30px;\"><span>}<\/span><\/pre>\n<p class=\"MsoNormal\"><span> <\/span><\/p>\n<p><span>To suppress the script to prompt for acceptance each time I added the following option<\/span><span><br \/>\n-Confirm:$FALSE<\/span><\/p>\n<p class=\"MsoNormal\"><span>The script easily be changed to add or update other VM hardware settings.<br \/>\n&#8211; Number of CPU&#8217;s<span> <\/span>(Set-VM <span> <\/span>&lt;vm-name&gt; -NumCpu 2)<\/span>\n<\/p>\n<p class=\"MsoNormal\"><span>&#8211; Rename VM<span> <\/span><span> <\/span>(Set-VM <span> <\/span>&lt;vm-name&gt; -Name &#8220;NewName&#8221;)<\/span><\/p>\n<p class=\"MsoNormal\">\n<p class=\"MsoNormal\"><span>Find more options and ideas in the &#8220;<a href=\"http:\/\/blogs.vmware.com\/vipowershell\/files\/vmworld_europe_2008_powershell_lab_7_manual.pdf\" target=\"_blank\">Automating VMware with PowerShell &#8211; Hands-On Lab<\/a>&#8221; from VMworls 2008.<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"color: #0000ff;\">Just remember if a VM is running you have to poweroff or shutdown the VM before the changes will take effect.<br \/>\nThis is because a restart or reset does&#8217;t reload the vmx file.<\/span>\n<\/p>\n<p class=\"MsoNormal\"><strong>Update:<\/strong><\/p>\n<p class=\"MsoNormal\">The script is now updates so it also implements the following settings<\/p>\n<ul>\n<li>Sets Memory Reservation to half of the amount of ram.<\/li>\n<li>Sets Memory Limit to \u00e2\u20ac\u0153Unlimited\u00e2\u20ac\u009d<\/li>\n<li>Sets the VM to check for new VMware Tools on PowerOn.<\/li>\n<li>Sets the VM to sync time from host.<\/li>\n<\/ul>\n<p>Take a look at the scripts <a href=\"http:\/\/www.amikkelsen.com\/?page_id=91\" target=\"_self\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I had to upgrade all our Jumphost VM&#8217;s from 256MB to 512MB of memory (more than 200 VM&#8217;s). There are two ways accomplice this. 1. Do it manually (Very time consuming) 2. Script it with PowerShell As the lazy person I am I decided that scripting was the way forward. The script I came\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.amikkelsen.com\/?p=97\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,21,4,16],"tags":[64,26,36,34,54,330,65,53,66,67,52],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-esx-i","category-powershell","category-scripting","category-esx-x","tag-allocation","tag-esx","tag-esxi","tag-get-vm","tag-memory","tag-powershell","tag-reservation","tag-set-vm","tag-sync","tag-time","tag-virtualcenter"],"_links":{"self":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=97"}],"version-history":[{"count":3,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":106,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions\/106"}],"wp:attachment":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}