VMware Cloud Community
MartijnBr
Contributor
Contributor

Change video card memory size

I want to change the size of the memory of the video card of a VM, because the default 4 MB isn't enough for our VDI. I used the script below to do this, but it doesn't work.

What goes wrong? We have over 2000 virtual desktops, so using a script is the only way.

============================================

(square bracket begin)Reflection.Assembly(square bracket end)::LoadWithPartialName("VMware.Vim")

Function ChangeVideoCard ($vmview)

{

$videocard = New-Object VMware.Vim.VirtualMachineVideoCard

$videocard.videoRamSizeInKB = 8000

$videocard.key = 500

$virtdev = New-Object VMware.Vim.VirtualDeviceConfigSpec

$virtdev.Device = $videocard

$virtdev.Operation = "edit"

$vmSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmSpec.DeviceChange = $virtdev

$taskImpl = $vmview.ReconfigVM_Task($vmSpec)

$task = Get-View $taskImpl

while (($task.info.state -eq "running") -or ($task.info.state -eq "queued"))

{$task = Get-View $taskImpl}

if ($task.info.state -eq "error")

{

$task.info.state

$task.info.error

$task.info.error.Fault

}

else

{

$task.info.state

}

}

Get-VIServer -Server "ticv5vmg.prod.cbs.local" -User "Administrator" -Password "xxxx"

$vm = Get-VM "test1" | % {Get-View $_.ID}

foreach ($device in $vm.config.hardware.device)

{

if ($device.key -eq 500) {$device}

}

ChangeVideoCard ($vm)

============================================

Output:

GAC Version Location

False v2.0.50727 C:\Program Files\VMware\Infrastructure\VIToolkitForWindows\VMwar...

Name : ticv5vmg.prod.cbs.local

Port : 443

VideoRamSizeInKB : 4096

Key : 500

DeviceInfo : VMware.Vim.Description

Backing :

Connectable :

ControllerKey : 100

UnitNumber : 0

DynamicType :

DynamicProperty :

error

Fault : VMware.Vim.InvalidDeviceOperation

LocalizedMessage : Invalid operation for device '0'.

DynamicType :

DynamicProperty :

BadOp : edit

BadFileOp : create

DeviceIndex : 0

Property :

DynamicType :

DynamicProperty :

Reply
0 Kudos
7 Replies
Niket
Enthusiast
Enthusiast

Plese refer the below script for the same.

Get-viserver -server

$vm = Get-VM "VMName" | % {Get-View $_.id}

$VMcidcrd = New-Object VMware.Vim.VirtualMachineVideoCard

$VMcidcrd.videoRamSizeInKB = 8000

$VMcidcrd.Key = 500

$spec = new-object VMware.Vim.VirtualDeviceConfigSpec

$spec.Device = $VMcidcrd

$spec.Operation = "edit"

$VMSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$VMSpec.DeviceChange = $spec

$vm.ReconfigVM_Task($VMSpec)

I hope it will resolve your issue.

Thanks

Niket

Reply
0 Kudos
MartijnBr
Contributor
Contributor

I still got the error message Invalid operation for device '0'. deviceIndex=0.

Am I missing something? It looks like VMware wants to change the wrong device. Or can it have something to do with VC 2.5 or ESX 3.0.2?

Reply
0 Kudos
Niket
Enthusiast
Enthusiast

It would work with ESX3.5. Please try to run it with this.

Reply
0 Kudos
MartijnBr
Contributor
Contributor

I updated the server to 3.5 update 1 and it works! Thanks!

Reply
0 Kudos
Midley
Contributor
Contributor

How to launch this script on virtual machine? Tanks for Help.

Reply
0 Kudos
Niket
Enthusiast
Enthusiast

Hi,

You can run the above script from Powesrshell console which includes VI Toolkit libraries as well. You need to specify the VM name which you want to reconfigure and make sure that VM should be on ESX/VC to which you are connecting using Connect-VIServer cmdlet.

Thanks

Niket

Reply
0 Kudos
alelondon
Enthusiast
Enthusiast

Hi MartinBr

Thanks for your post, and thanks Niket for your reply too. MartinBr, you mentioned that 4MB isn't enough for your VDI. We are also deploying VDI and have been experiencing some erractic graphic behaviours on our VMs. When it happens (and we can't reproduce it 😐 ), one ramdom application will get a taskbar button at the bottom of the page, but we only see the white space on the screen where that app would be displayed. Other apps that were already open may or may not still work. Once it happens, any other application launched will also behave the same way: You get the button in the taskbar, but just a white space is displayed. Logging off and back on (not restart) resolved the issue.

Would you mind sharing what symptoms you were experiencing that resorted to an updgrade to the video card memory ? And also, has the upgrade eventually fixed your issues?

Many many thanks all

Reply
0 Kudos