VMware: Generate an URL for a VM Console Session

Hi,

with PowerCli it is simply possible to generate an direct Link to accessing a VM’s Console without clicking through the whole vSphere Tree.

The anatomy of the URL is
https://%vCenterFQDN%:9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:%MoRef%:%vCenterUUID%

function fGenerateWebfrontendURL([string]$sVM,[string]$sVCenter)
{
    $oVM=Get-VM $sVM -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
    $oVCenter=Get-VIServer $sVCenter -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
    if($oVM -and $oVCenter)
    {
        $sURL="https://"+$sVCenterHost+":9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:"+($oNewVM.ExtensionData.MoRef.Value)+":"+$oVCenter.InstanceUuid.ToUpper()
        return $sURL
    }
    return $null
}

PS D:\> fGenerateWebfrontendURL myVM myVcenter

Michael

3 thoughts on “VMware: Generate an URL for a VM Console Session”

Leave a Reply Cancel reply