{"id":570,"date":"2011-04-27T14:51:50","date_gmt":"2011-04-27T13:51:50","guid":{"rendered":"http:\/\/www.amikkelsen.com\/?p=570"},"modified":"2011-05-06T12:36:23","modified_gmt":"2011-05-06T11:36:23","slug":"changing-the-virtual-videocard-settings","status":"publish","type":"post","link":"https:\/\/www.amikkelsen.com\/?p=570","title":{"rendered":"Changing the virtual videocard settings"},"content":{"rendered":"<p>Some time ago I was asked to create a script that could list each VM\u00e2\u20ac\u2122s videocard settings. <\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$VMs = Get-View -ViewType VirtualMachine | sort Name \r\nforeach($VM in $VMs){\r\n\twrite &quot;$($VM.Name) $($VM.Guest.Screen.Width)\/$($VM.Guest.Screen.Height)&quot;\r\n}\r\n<\/pre>\n<p>As you could see that was quite simple.<br \/>\nI using the Get-View -ViewType to speed up the query \u00e2\u20ac\u201c See LucD\u00e2\u20ac\u2122s post on <a href=\"http:\/\/communities.vmware.com\/message\/1511671#151167\">http:\/\/communities.vmware.com\/message\/1511671#1511671<\/a> for more info.<\/p>\n<p>Then I was asked to set all VM\u00e2\u20ac\u2122s videocard setting to Auto Detect (Default setting).<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$vms = Get-View -ViewType VirtualMachine | sort Name\r\nforeach ($vm in $vms){\r\n\tif ($vm.Runtime.PowerState -eq &quot;PoweredOff&quot;) {\r\n\t\tif ($vm.Config.Version -eq &quot;vmx-07&quot;){ \r\n\t\t\tforeach($dev in $vm.Config.Hardware.Device){\r\n\t\t\t\tif ($dev.DeviceInfo.Label -like &quot;Video*&quot;){\r\n\t\t\t\t\tif ($dev.UseAutoDetect -match &quot;False&quot; ) {\r\n\t\t\t\t\t\t$VMName = $vm.Name\r\n\t\t\t\t\t\t$VMcidcrd = New-Object VMware.Vim.VirtualMachineVideoCard \r\n\t\t\t\t\t\t$VMcidcrd.UseAutoDetect = 1\r\n\t\t\t\t\t\t$VMcidcrd.Key = 500\r\n\t\t\t\t\t\t$spec = new-object VMware.Vim.VirtualDeviceConfigSpec\r\n\t\t\t\t\t\t$spec.Device = $VMcidcrd\r\n\t\t\t\t\t\t$spec.Operation = &quot;edit&quot;\r\n\t\t\t\t\t\t$VMSpec = New-Object VMware.Vim.VirtualMachineConfigSpec\r\n\t\t\t\t\t\t$VMSpec.DeviceChange = $spec\r\n\t\t\t\t\t\t$vm.ReconfigVM_Task($VMSpec)\r\n\t\t\t\t\t\twrite &quot;$($vm.Name) - Video Settings Changed&quot;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>As you can see this requires a bit more.<br \/>\nThe VM has to be<br \/>\n\u00e2\u20ac\u00a2\tPowered Off<br \/>\n\u00e2\u20ac\u00a2\tRunning vHW version 7<br \/>\nDownload the full script <a href=\"\/files\/powershell\/videocard_to_auto_v01.ps1\">here<\/a>.<\/p>\n<p>If you want to set the videocard setting to a specific MB, then just change the line from the above script<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$VMcidcrd.UseAutoDetect = 0\r\n<\/pre>\n<p>To<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$VMcidcrd.UseAutoDetect = 0\r\n<\/pre>\n<p>And add the line<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$VMcidcrd.VideoRamSizeInKB = 131072\r\n<\/pre>\n<p>Where the 131072 us the amount of MB you want multiplied with 1024<br \/>\nEx. 128 x 1024 = 131072<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some time ago I was asked to create a script that could list each VM\u00e2\u20ac\u2122s videocard settings. $VMs = Get-View -ViewType VirtualMachine | sort Name foreach($VM in $VMs){ write &quot;$($VM.Name) $($VM.Guest.Screen.Width)\/$($VM.Guest.Screen.Height)&quot; } As you could see that was quite simple. I using the Get-View -ViewType to speed up the query \u00e2\u20ac\u201c See LucD\u00e2\u20ac\u2122s post on\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.amikkelsen.com\/?p=570\">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":[21,4],"tags":[281,138,280,279,117],"class_list":["post-570","post","type-post","status-publish","format-standard","hentry","category-powershell","category-scripting","tag-auto-detect","tag-powercli","tag-setting","tag-videocard","tag-vm"],"_links":{"self":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/570","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=570"}],"version-history":[{"count":6,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":576,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=\/wp\/v2\/posts\/570\/revisions\/576"}],"wp:attachment":[{"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amikkelsen.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}