WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
    • VMware Cloud Foundation 9
  • VKS
  • Homelab
    • Hardware Options
    • Hardware Reviews
    • Lab Deployment Scripts
    • Nested Virtualization
    • Homelab Podcasts
  • VMware Nostalgia
  • Apple
You are here: Home / vSphere 7.0 / How to forcefully disconnect a vSphere VM Console session?

How to forcefully disconnect a vSphere VM Console session?

06.24.2022 by William Lam // 2 Comments

The vSphere Virtual Machine Console UI is an extremely useful interface for interacting with a VM, especially for initial configurations and/or debugging and troubleshooting purposes, such as an issue with networking. The VM console is analogous to connecting a physical keyboard and monitor to a computer, you remember the good ol' days right? 😀

Unlike the physical world, where you can only have a single person interacting with the computer, the vSphere VM Console can allow multiple users to view and interact with the VM. It is also not uncommon for customers to limit the number of simultaneous VM Console sessions, especially for security and/or for privacy purposes.


One potential down side with limiting the VM Console session to one is that another user may not be able to connect until the other session has concluded and/or has expired due to lack of activity. This recently came up as a question from a customer asking if there was a way to forcefully disconnect an existing VM Console connection?

I was not aware of any practical methods but pinging one of our Engineers, I came to learn that we actually had introduced a new vSphere API that would assist in this very use case and was introduced back in vSphere 7.0 Update 1. The new vSphere API is called DropConnections(), which is very straight forward to use and can disconnect one or more existing VM Console connections. To list all active VM Console sessions, another new vSphere API was introduced called QueryConnections().

To demonstrate these two new vSphere APIs, I will be using PowerCLI to invoke the vSphere API using a VM in my environment called ph-clone.

(Get-VM -Name ph-clone).ExtensionData.QueryConnections()

As you can see from the command above, the QueryConnections() API is performed on a specific VM and the results is a set of connection(s) with three fields: Label, Client and UserName.


Note: The UserName for vSphere H5 Client VM Console will always show up as root and for any Standalone VMRC VM Console, the UserName will simply show up as VNC User, which can help distinguish the type of method used to connect to VM Console.

To disconnect a specific VM Console connection, we will need the three fields from above as they are all required to identify a specific VM Console session to perform the disconnect

The DropConnections() API can disconnect a list of active VM Console session and in the example below, we are simply disconnecting a single session.

$connection = New-Object VMware.Vim.VirtualMachineConnection
$connection.Label = "4"
$connection.Client = "192.168.30.3"
$connection.UserName = "root"

(Get-VM -Name ph-clone).ExtensionData.DropConnections(@($connection))

If the VM Console session disconnect was successful, you will get a result of True as shown in the screenshot below.


If you navigate to the existing VM Console session that you had been opened prior, you will see the following when it is remotely disconnected using this API.


If you are ever in a crunch and needing to disconnect an active VM Console, this is definitely a handy vSphere API to be aware of! If you are not running vSphere 7.0 Update 1, one other method that can be used to quickly disconnect VM Console session(s) is by performing a vMotion of the VM, this has been used by few customers in the past.

Note: Although Standalone VMRC VM Console connections are listed in QueryConnections() API and can be disconnected using DropConnections() API, the VMCR client has built-in session re-establishment, so you will see that a new session is spawn even when you attempt to disconnect an active session.

Categories // vSphere 7.0 Tags // vm console, vmrc, vSphere 7.0 Update 1

Comments

  1. *protectedyafa rok says

    11/29/2023 at 2:22 am

    Hi, thanks for the information!
    I was wondering about the last paragraph - do you have any idea how to prevent standalone vmrc from keep reconnecting?

    Reply
  2. *protectedMikeP says

    06/17/2025 at 6:40 am

    vMotioning the VM to another system disconnects the console. and allows someone else to connect. Seems like an easier solution than what is proposed here assuming you can do a vMotion.

    Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Quick Tip - NSX Edge fails DNS pre-check as part of VCF 9.0.2 Upgrade 01/23/2026
  • Quick Tip - No space left on device when upgrading VCF Operations using VCF Operations Fleet Manager to VCF 9.0.2 01/22/2026
  • Every Mini PC & SFF Hardware Announced at CES 2026 01/21/2026
  • Improved Workaround for NSX Edge Deployment & Upgrade to VCF 9.0.2 running AMD Ryzen CPUs 01/20/2026
  • Disable HTTP Range Requests on Synology WebStation, Apache or Nginx 01/14/2026

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.

To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2026

 

Loading Comments...