Direct Link to VM in the vCenter HTML5 interface.

Written by Luke Arntz on November 20, 2019
[ vCenter ] [ code ] [ csharp ]

Contents

Why

I find it useful when I generate automated reports to have a link directly to the virtual machine(s) in the report. The example below is written in C#, but the link format is the same regardless of way it is generated.

Link Structure Info

Link contains:

  • VM MoRef (value only)
  • vCenter UUID

HTML Format

https://vcenter.megacorp.com/ui/#?extensionId=vsphere.core.vm.summary&objectId=urn:vmomi:VirtualMachine:vm-143:a198f2b8-3427-40f4-a4e1-93f6ee5c6999&navigator=vsphere.core.viTree.vmsAndTemplatesView

C# Example

Regex serverFromURL = new Regex(@"(?'server'^https://\S+\.\S+\.\S+)/sdk");
Match server = serverFromURL.Match(vimClient.ServiceUrl);
String.Format("<a href=\"{0}/ui/#?extensionId=vsphere.core.vm.summary&objectId=urn:vmomi:VirtualMachine:{1}:{2}&navigator=vsphere.core.viTree.vmsAndTemplatesView\">{3}</a>", server.Groups["server"],virtualMachine.MoRef.Value, vimClient.ServiceContent.About.InstanceUuid, virtualMachine.Named);

Reference

https://www.virtuallyghetto.com/2011/10/how-to-generate-vm-remote-console-url.html

Related Articles

Top