VMware Cloud Community
Chrigoli
Enthusiast
Enthusiast

Build URLs for: VM Console, vCloud Director vApp, VM properties in vSphere

Hi all

I made a script to generate URLs for the following access:

- Open a VM's Console in vSphere Web Client

- Open vApp (to which the VM corresponds to) in vCloud Director

- Open the VM's Summary Tab in vSphere Web Client

I used that to generate a list of all my VMs within vCloud Director. Makes it much easier to manage if I have direct links to the Console and the vApp. Hope this might be of interest for some of you.

Cheers

Chrigoli

-----------------------------------

#Variables

$vCenterName = "your vCenter like vc1.domain.com"

$vCloudDirName = "your vCloud Director like cell1.domain.com"

#Connect to vCloud Cell and vCenter

Connect-CIServer -Server $vCloudDirName

Connect-VIServer -Server $vCenterName

#vCenterInstance ID

$vCenterInstanceID =  $DefaultVIServers[0].InstanceUuid

#Objects

$vivm = "My VM, could be f.e. while looping through a list of all VMs"

$vApp = "The vApp in vCloud Director"

#VM MoRef -> required for Console URL and vSphere Summary URL

$vmMoRef = $vivm.ExtensionData.MoRef.ToString()

$vmMoRef = $vmMoRef.Substring(15,$vmMoRef.Length-15)

#vAppMoRef and OrgMoRef, required for the vCloud Director vApp URL

$vAppMoRef = $vApp.Id

$vAppMoRef = $vAppMoRef.Substring(16,$vAppMoRef.Length-16)

$OrgMoRef = $vApp.Org.Id

$OrgMoRef = $OrgMoRef.Substring(15,$OrgMoRef.Length-15)

#Console URL

$ConsoleURL = "https://" + $vCenterName + ":9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:" + $vmMoRef + ":" + $vCenterInstanceID.ToUpper()

                       

#vCloud vApp URL

$vcloudURL = "https://" + $vCloudDirName + "/cloud/#/vAppDiagram?vapp=" + $vAppMoRef + "&org=" + $OrgMoRef                     

                       

#vSphere Summary URL

$vsphereURL = "https://" + $vCenterURL + ":9443/vsphere-client/#extensionId=vsphere.core.vm.summary;context=com.vmware.core.model%3A%3AServerObjectRef~" + $vCenterInstanceID.ToUpper() + "%3AVirtualMachine%3A" + $vmMoRef + "~core"

0 Kudos
2 Replies
LucD
Leadership
Leadership

Thanks for sharing that.

I moved the thread to the vCloud Director PowerCLI community.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
madhanSakthi
Contributor
Contributor

HI,

is it possible to create a console url for a vm in a VApp ?

0 Kudos