Hi,
am looking for an automated way to set the video ram of VM's to "auto" to get rid of those pesky mesages we see in vCenter & in our monitoring tools:
Insufficient video RAM. The maximum resolution of the virtual machine will be limited to 1176x885 at 16 bits per pixel. To use the configured maximum resolution of 2360x1770 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.
Is this at all possible with PowerCLI & did anybody succeeded in doing this? Any help is appreciated.
Regards, Peter
Afaik, there is currently no cmdlet that allows you to do that.
But you can use the ReconfigVM_Task method to set the video RAM to 'auto'.
The following function will change the setting to 'auto'.
function Set-VideoRamAuto{ param( [parameter(valuefrompipeline = $true )] [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl]$VM
) process{ $vidDev = $vm.ExtensionData.Config.Hardware.Device | where {$_.DeviceInfo.Label -like "Video*"} $spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.operation = "edit"
$vidDev.UseAutoDetect = $true
$dev.Device += $vidDev
$spec.DeviceChange += $dev $vm.ExtensionData.ReconfigVM($spec) } }
You can call the function like this
Set-VideoRamAuto -VM (Get-VM MyVM)
But you can also use it in a pipeline construction
Get-VM | Set-VideoRamAuto
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
Thank you very much for the function, what would we do without you 😉
Small remark though: For some reason when I use the function to update all the VM's in 1 shot "Get-VM | Set-VideoRamAuto", I get error messages and sometimes the reconfiguration operation fails randomly on a couple of VM's, let's say I have a success rate of about 80%.
Now when I manually execute the function like this "Set-VideoRamAuto -VM (Get-VM MyVM)", it even fixes the VM's that had previously failed & doesn't generate errors...
Errors:
Exception calling "ReconfigVM" with "1" argument(s): "The operation is not supported on the object."
At C:\Users\id917130a\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.
ps1:155 char:37
+ $vm.ExtensionData.ReconfigVM <<<< ($spec)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Method invocation failed because [VMware.Vim.VirtualMachineVideoCard] doesn't contain a method named 'op_Addition'.
At C:\Users\id917130a\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.
ps1:153 char:17
+ $dev.Device += <<<< $vidDev
+ CategoryInfo : InvalidOperation: (op_Addition:String) [], Runti
meException
+ FullyQualifiedErrorId : MethodNotFound
Am i missing something here?
In a big environment like ours, it would be nice to use the 1 shot scenario, but then it will be very hard to manage/identify the "failed" VM's.
Do you know a way to list the VM's that are not set to "auto"
Tnx!!
Grtz, Peter
No, you aren't missing anything, I made a mistake with the begin section in the function.
The function is updated, it should be better now.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
That did the trick, thanks again, very valuable!
Regards, Peter