[ 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
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