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

Advertisment to support michlstechblog.info

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

  1. This does not seem to be working for vcenter6.5. Could you provide url format and ways to generate url for vcenter6.5

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.