WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / Automation / Generating a vSphere UI link to a specific Virtual Machine

Generating a vSphere UI link to a specific Virtual Machine

04.05.2023 by William Lam // 2 Comments

For some organizations, after a VM has been provisioned, it is customary to send a notification (email, slack, etc) to their end users with login credentials including the URL for the vSphere UI.

Typically, the provided URL is just the vCenter Server base URL and end users would then have to login and navigate to their specific VM(s) within the vSphere Inventory. A question was brought up on whether a better end user experience could be provided to their internal users? They were interested in providing their end users with a specific URL link that would take them directly to their VM, which they can also bookmark for future uses.

Furthermore, the customer was also interested in generating the URL programmatically, so that it can be incorporated into their existing provisioning workflows.

This can easily be achieved as each inventory object in the vSphere UI has a unique URL. For the purpose of this blog post, I will primarily be focusing on the VM inventory object, which can exists under the Hosts/Clusters view or VM/VM Templates view, but the concept will apply to other vSphere Inventory objects.

Under the Hosts/Clusters view, the URL for a VM would look like the following: https://vcsa.primp-industries.local/ui/app/vm;nav=h/urn:vmomi:VirtualMachine:vm-40043:056a402b-2b3d-4f74-93f7-fa818adff697/summary

Under the VM/VM Template view, the URL for a VM would look like the following: https://vcsa.primp-industries.local/ui/app/vm;nav=v/urn:vmomi:VirtualMachine:vm-40043:056a402b-2b3d-4f74-93f7-fa818adff697/summary

As you can see from both URLs above, the only difference is the "nav=" key that specifies whether the view is in the Hosts/Clusters (h) or VM/VM Templates (v) and the rest of the URL is the same including the VM Managed Object Reference (MoRef) ID in blue and the vCenter Server Instance UUID in orange.

With all of this information, we can easily automate the generation of the URL for a specific VM within the vSphere UI. To demonstrate this, we will be using the vSphere API and consuming that through PowerCLI with the following snippet:

$vmName = "Rocky-Linux-9"
$uiView = "v"

$vcHostname = $global:DefaultVIServer.name
$vcInstanceUUID = $global:DefaultVIServer.InstanceUuid
$vmId = ((Get-VM $vmName).id).replace("VirtualMachine-","VirtualMachine:")

Write-Host "https://${vcHostname}/ui/app/vm;nav=${uiView}/urn:vmomi:${vmId}:${vcInstanceUUID}/summary"

Note: Users will still need to login to vCenter Server even with the direct link to their VM and if they do not have the appropriate permissions, they will not be able to view or do anything.

More from my site

  • vSphere Code Capture is your ChatGPT for vSphere Automation
  • Creating custom ESXi images using vSphere Lifecycle Manager (vLCM) UI and PowerCLI cmdlets for vSphere 8
  • How to restrict vSphere UI access while maintaining vSphere API functionality?
  • Exploring VSAN APIs Part 3 – Enable VSAN Traffic Type
  • How to Automate the Deployment & Configuration of vShield Manager 5

Categories // Automation, vSphere, vSphere Web Client Tags // vSphere UI

Comments

  1. *protectedhenketh says

    04/06/2023 at 1:02 am

    Where do I find the "VM Managed Object Reference (MoRef) ID and the vCenter Server Instance UUID" for a specific VM?

    Reply
    • William Lam says

      04/06/2023 at 10:29 am

      Did you take a look at the blog post, the details are there 🙂

      Reply

Thanks for the comment!Cancel reply

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

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC) across Private, Hybrid and Public Cloud

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • vSphere Code Capture is your ChatGPT for vSphere Automation 11/30/2023
  • ESXi 8.0 Update 2 not detecting Apple NVMe on Apple Mac Mini 2018 11/28/2023
  • Is there a vSphere REST API for ... 11/21/2023
  • Custom vSAN HCL JSON for VMware Cloud Foundation (VCF) 5.1 and vSAN ESA using Nested ESXi 11/20/2023
  • Heads Up - Performance Impact with VMware Workstation on Windows 11 with Intel Hybrid CPUs 11/19/2023

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 © 2023

 

Loading Comments...