vSphere Security Guide suggests to "Minimize Use of the Virtual Machine Console" by limiting the number of parallel connections to the virtual machine console.
However, documented procedure suggests changing the settings across the fleet of virtual machine one by one using the UI options.
This document provides an automation approach using PowerCLI so that set of virtual machines can be updated in batches
VMware vCenter Server
Advanced setting that limits the console connections is named as "RemoteDisplay.maxConnections". We can change this using the PowerCLI based automation.
Though this setting can be changed using automation, changes are effective only after the virtual machine process is cold started. You can use the VMotion feature to achieve the same effect as migrating the virtual machine to another host will restart the virtual machine process.
Connect-VIServer -Server VCENTER_SERVER -Protocol https
Updating Settings for a named Virtual machine
Get-VM -Name VMNAME| New-AdvancedSetting -Name RemoteDisplay.maxConnections -Value X -Force
Updating Setting for all virtual machines in a cluster.
Get-Cluster -Name CLUSTER_NAME | ForEach-Object -Process {
Get-VM | ForEach-Object -Process {
New-AdvancedSetting -Entity $_ -Name RemoteDisplay.maxConnections -Value X -Confirm:$false -Force
}
}
Note: This action on some solution virtual machines like vCLS Virtual Machines may fail as altering the settings is not supported. While running the changes cluster wide, on screen error for these virtual machines can be safely ignored. Script would continue to update other virtual machines.
Post applying the changes, migrate the virtual machine to another host using VMotion in order to make the changes effective.
VMotion of virtual machine will also disconnect all the existing HTML console connections to the virtual machine. This approach can be used to forcefully disconnect any existing connections in case they are deemed stale.