Description:

This script allows you to set the Video Hardware Acceleration Level of all your powered on, Windows virtual machines to Full.

Code:

###########################
# Set-VMVideoAccLevel.ps1 #
# Created by Hugo Peeters #
#  www.peetersonline.nl   #
###########################
 
# Variables
$Hive = "LocalMachine"
$RefKeyName = 'HARDWAREDEVICEMAPVIDEO'
$LookupValue = 'Acceleration.Level'
$errorActionPreference = "SilentlyContinue"
$Writeable = $True
$Full = 0
$Off = 5
 
# Script
Add-PSSnapIn VMware.VimAutomation.Core
$VC = Connect-VIServer (Read-Host "VC Server")
$VMS = Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Sort Name
ForEach ($VM in $VMS)
{
	$ServerName = $VM.Guest.HostName
	$Registry = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::$Hive, $ServerName)
	$RefKey = $registry.OpenSubKey($RefKeyName)
	$RefValues = $RefKey.GetValueNames() | Where {$_ -match "Video"}
	ForEach ($RefValue in $RefValues)
	{
		$LookupKeyName = $RefKey.GetValue($RefValue).TrimStart("RegistryMachine")
		$LookupKey = $Registry.OpenSubKey($LookupKeyName,$Writeable)
		$Result = $LookupKey.GetValue($LookupValue)
		If ($Result -eq $Off)
		{
			Write-Host "Modifying Hardware Acceleration Level on VM " -NoNewLine
			Write-Host $VM.Name
			$LookupKey.SetValue($LookupValue,$Full)
		}
		ElseIf ($Result -eq $Full)
		{
			Write-Host "Hardware Acceleration is already set to full on VM" -NoNewLine
			Write-Host $VM.Name
		}
		Clear-Variable Result
		Clear-Variable LookupKeyName
		Clear-Variable LookupKey
	}
	Clear-Variable ServerName
	Clear-Variable Registry
	Clear-Variable RefKey
	Clear-Variable RefValues
}
Disconnect-VIServer -Confirm:$False

Download:
Set-VMVideoAccLevel (Rename to .ps1)

Disclaimer:

All the scripts on PeetersOnline.nl are published under a Creative Commons license, which means you should refer to me if you want to republish (pieces of) them. Thank you. More information about Creative Commons can be found here: Creative Commons Attribution 3.0 Netherlands License.

Creative Commons License