VMware PowerShell VM Console Connections

VMware PowerShell VM Console Connections

Here is a quick outline of how you can use PowerShell to interrogate and change the configuration of the number of VM console connections permitted to connect to a virtual machine.

The main focus of attention here is “RemoteDisplay.maxConnections” which can be used to limit the number of simultaneous connections to a Virtual Machine, this isn’t something that is always set, so first a command to find out where the configuration is set.

Where is RemoteDisplay.maxConnections configured?

As with most of the PowerShell I share, I’ll keep it to one line and provide an option to export to a CSV etc and I’ll assume you are already connected to virtual center (Connect-VIServer)

$VM = Get-VM 
$VM | Get-AdvancedSetting -Name RemoteDisplay.maxConnections | Export-CSV C:\RemoteDisplayMaxConnections.csv 

To give you an idea of the output, I’ve change the command ever so slightly to format the output as a list rather than exporting to a CSV.

The output is showing that the following VMs in this list have a “RemoteDisplay.maxConnections” configuration that limits RemoteDisplay connections to only 1.

How Many Connections are being made to a VM?

If you want to see how many connections are being made to a particular Virtual Machine, you can do that when you have the Virtual Machine name.

$VM = get-view -viewtype VirtualMachine -filter @{"Name"="nsx-mgmt-1"}
$VM.Runtime.NumMksConnections

This will provide output similar to the below

 

Configure RemoteDisplay.maxConnections?

The below PowerCLI can be used to Set, Edit and Unset the RemoteDisplay.maxConnections value

Set
----

Get-VM "VM_NAME" | New-AdvancedSetting -Name RemoteDisplay.maxConnections -Value 4 -Confirm:$false
 
Edit
----
Get-VM "VM_NAME" | Get-AdvancedSetting -Name RemoteDisplay.maxConnections | Set-AdvancedSetting -Value 2 -Confirm:$false
 
Unset
-----
Get-VM "VM_NAME" | Get-AdvancedSetting -Name RemoteDisplay.maxConnections | Remove-AdvancedSetting -Confirm:$false

Summary

The PowerShell methods shared in this post can be used to Check, Audit, Set, Edit and remove the configurations required to limit the number of simultaneous connections to a Virtual Machine.

Thanks

Simon