Virtu-Al.Net

Virtually everything is poshable

Change VM Video Memory

I was contacted by a colleague asking if there was an easy way to set the video memory for a number of virtual machines, he had been working with a customer who had received an error when a virtual machine was being Vmotioned, the Vmotion completes successfully but the following error is received:

Insufficient video RAM. The maximum resolution of the virtual machine will be limited to 1176×885 at 16 bits per pixel. To use the configured maximum resolution of 2360×1770 at 16 bits per pixel, increase the amount of video RAM allocated to this virtual machine by setting svga.vramSize=”16708800″ in the virtual machine’s configuration file.

After applying his best Google-Fu he managed to find the following KB article: http://kb.vmware.com/kb/1014593

This clearly tells him the issue and how to resolve this by changing the video memory on the virtual machine, however, after changing this setting he then came across another issue as SRM was unable to protect these virtual machines as described in this KB article: http://kb.vmware.com/kb/1020796

The long and the short of it was that he needed to change the video memory in over 3000 VMs, you can of course do this in the vCenter client using the following screen but for 3000 VMs this may take a while !

Vide card settings

PowerCLI to the rescue !

With the following PowerCLI function he will be able to adjust a number of VMs without spending hours pointing and clicking.

function Set-VMVideoMemory {
<# .SYNOPSIS   Changes the video memory of a VM .DESCRIPTION   This function changes the video memory of a VM .NOTES   Source: http://virtu-al.net   Author: Alan Renouf   Version: 1.1 .PARAMETER VM   Specify the virtual machine .PARAMETER MemoryMB   Specify the memory size in MB .EXAMPLE   PS> Get-VM VM1 | Set-VMVideoMemory -MemoryMB 4 -AutoDetect $false
#>

  Param (
    [parameter(valuefrompipeline = $true, mandatory = $true, HelpMessage = "Enter a vm entity")]
    [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl]$VM,
    [int64]$MemoryMB,
	[bool]$AutoDetect,
	[int]$NumDisplays
   )

  Process {
	$VM | Foreach {
		$VideoAdapter = $_.ExtensionData.Config.Hardware.Device | Where {$_.GetType().Name -eq "VirtualMachineVideoCard"}
		$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
		$Config = New-Object VMware.Vim.VirtualDeviceConfigSpec
		$Config.device = $VideoAdapter
		If ($MemoryMB) {
			$Config.device.videoRamSizeInKB = $MemoryMB * 1KB
		}
		If ($AutoDetect) {
			$Config.device.useAutoDetect = $true
		} Else {
			$Config.device.useAutoDetect = $false
		}
		Switch ($NumDisplays) {
			1{ $Config.device.numDisplays = 1}
			2{ $Config.device.numDisplays = 2}
			3{ $Config.device.numDisplays = 3}
			4{ $Config.device.numDisplays = 4}
			Default {}
		}
		$Config.operation = "edit"
		$spec.deviceChange += $Config
		$VMView = $_ | Get-View
		Write-Host "Setting Video Display for $($_)"
		$VMView.ReconfigVM($spec)
	}
  }
}

# For a single VM setting the video memory to 4MB
Get-VM VIEW01 | Set-VMVideoMemory -MemoryMB 4 -AutoDetect $false

# For all VMs on a Host setting the vide memory to Auto Detect
Get-VMHost Host01 | Get-VM | Set-VMVideoMemory -AutoDetect $true

# For all VMs in a cluster to set the Video Memory to 8MB
Get-Cluster Production | Get-VM | Set-VMVideoMemory -MemoryMB 8 -AutoDetect $false

11 Responses to “Change VM Video Memory”

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>