Getting VMRC links with Python

It became quite a pain to get Web-based console working on ESXi hosts or vCenter servers with deprecation of NPAPI plugins in modern browsers. As for me, the most comfortable method to get a remote console access is to use standalone Virtual Machine Remote Console client (VMRC) which is available for free for major OSes. The sad part about VMRC is that you have to login to ESXi web client/vCenter, choose a desired VM and click on Launch VMRC link to get access. Too many unnecessary and annoying steps to take.

In my day to day work I have to deal with 2-4 VMs and what I want is to have their consoles 1-click away. In this post I’ll share a tiny Python script which composes links for VMs suitable for VMRC:  vmrc://root@ . Click on the previous link will trigger VMRC to connect to virtual console of a VM.

As you see, vmrc relies on specifically defined URLs. Lets take a closer look at VMRC link we have to get from VMWare –  vmrc://root@ . You should specify a user that have access to console on your VM, FQDN or IP address of ESXi host/vCenter and SSL port for connection to an ESXi host (or a vCenter server if you have it), and moid . If the former variables are well-known for you, the latter wont be so easy to achieve.

MOID (MoRef ID or Managed Object Reference ID) – is a unique value that is generated by the vCenter Server/ESXi host and is guaranteed to be unique for a given entity in a single vCenter instance. To get this ID you can utilize several manual and automatic methods.

Manual MoID retrieval

If you like things manual and have access to ESXi host console, you can use this command to list all VMs and their MoIDs:

Vmid here stands for MoID.

Another way to get MoID is to web-navigate through Managed Object Browser (MOB) as detailed in this KB and in details by William Lam here. This works for vCenter servers as well, so if you have an access to vCenter server – you can retrieve MoID for every VM managed by it.

Automatic MoID retrieval

Manual mode is OK, but everything is better with automation. Above mentioned William Lam has a perl script for you to retrieve MoIDs, read his post on how to use it.

If you are more familiar with Python than I want to share with you this little script (github). I took a sample script from VMWare API for Python (pyvmomi on github) and added few string to retrieve MoID and ESXi 5.1 hosts support.

You can run this scrip without modifying single string of code:

As you see this script produces the whole VMRC link which you can paste to a browser and get console access via VMRC standalone client. Though I was lazy enough to add a vm_name option to get just one VM summary block instead of all the VMs on ESXi/vCenter, but you can always fork-improve-pullreq :)


Roman Dodin

Network engineer at Nokia
Eagerness to learn multiplied by passion to share.
You can reach me at LinkedIn

You Might Also Like