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"