VMware Cloud Community
VSnip
Enthusiast
Enthusiast
Jump to solution

vSphere Client 6.5 HTML5 - Generate a link to access to Summary page for a VM

Hi guys!

I would like to generate a link in order to be able to access to "Summary" page of a VM.


I found this article from William Lam:

https://www.virtuallyghetto.com/2013/09/how-to-generate-pre-authenticated-html5.html

but the William's function generate a link in order to access to the VM console.

In my case, I would like to access to Summary page where we can find "VM Hardware", "Related Objects", "Notes", ... sections.

Here an example of page I would like to access via the generated link:

pastedImage_0.png

I didn't find what I would. If someone found a blog, article or script that help me to generate this kind of link, it will be great!

I tried to look the function and what modify but I'm not an expert in powercli/powershell. :smileycry:

Can you help me? please

Informations:

vCenter 6.5

vSphere Client 6.5 - HTML5

I hope I was clear in my description. Don't hesitate to ask more information.

Thanks!

Reply
0 Kudos
1 Solution

Accepted Solutions
VSnip
Enthusiast
Enthusiast
Jump to solution

Hello,

Last week, I found the solution, I modified the William's script for my needs:

Function Get-VMConsoleURL {

<#

    .NOTES

    ===========================================================================

    .DESCRIPTION

  Generate a link that open the vSphere console for a specific VM

    .PARAMETER VMName

        The name of the VM

    .EXAMPLE

        Get-VMConsoleURL -VMName "Embedded-VCSA1"

#>

    param(

        [Parameter(Mandatory=$true)][String]$VMName

         )

    Function Get-SSLThumbprint {

        param(

        [Parameter(

            Position=0,

            Mandatory=$true,

            ValueFromPipeline=$true,

            ValueFromPipelineByPropertyName=$true)

        ]

        [Alias('FullName')]

        [String]$URL

        )

        add-type @"

            using System.Net;

            using System.Security.Cryptography.X509Certificates;

                public class IDontCarePolicy : ICertificatePolicy {

                public IDontCarePolicy() {}

                public bool CheckValidationResult(

                    ServicePoint sPoint, X509Certificate cert,

                    WebRequest wRequest, int certProb) {

                    return true;

                }

                }

"@

        [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy

        # Need to connect using simple GET operation for this to work

        Invoke-RestMethod -Uri $URL -Method Get | Out-Null

        $ENDPOINT_REQUEST = [System.Net.Webrequest]::Create("$URL")

        $SSL_THUMBPRINT = $ENDPOINT_REQUEST.ServicePoint.Certificate.GetCertHashString()

        return $SSL_THUMBPRINT -replace '(..(?!$))','$1:'

    }

   $VM = Get-VM -Name $VMName

   $VMMoref = $VM.ExtensionData.MoRef.Value

   $VCInstasnceUUIDOriginal = $global:DefaultVIServer.InstanceUuid

   $VCInstasnceUUID = $VCInstasnceUUIDOriginal.ToUpper()

   $VCName = $global:DefaultVIServer.Name

   $SessionMgr = Get-View $DefaultViserver.ExtensionData.Content.SessionManager

   $Ticket = $SessionMgr.AcquireCloneTicket()

   $VCSSLThumbprint = Get-SSLThumbprint "https://$VCname"

   $URL = "https://$VCName/ui/#?extensionId=vsphere.core.inventory.serverObjectViewsExtension&objectId=urn:vmom..."

   $URL

$VM = Get-VM -Name $VMName

   $VMMoref = $VM.ExtensionData.MoRef.Value

   $VCInstasnceUUIDOriginal = $global:DefaultVIServer.InstanceUuid

   $VCInstasnceUUID = $VCInstasnceUUIDOriginal.ToUpper()

   $VCName = $global:DefaultVIServer.Name

   $SessionMgr = Get-View $DefaultViserver.ExtensionData.Content.SessionManager

   $Ticket = $SessionMgr.AcquireCloneTicket()

   $VCSSLThumbprint = Get-SSLThumbprint "https://$VCname"

   $URL = "https://$VCName/ui/#?extensionId=vsphere.core.inventory.serverObjectViewsExtension&objectId=urn:vmom..."

   $URL

}

}

I hope it will help you. 🙂

View solution in original post

Reply
0 Kudos
1 Reply
VSnip
Enthusiast
Enthusiast
Jump to solution

Hello,

Last week, I found the solution, I modified the William's script for my needs:

Function Get-VMConsoleURL {

<#

    .NOTES

    ===========================================================================

    .DESCRIPTION

  Generate a link that open the vSphere console for a specific VM

    .PARAMETER VMName

        The name of the VM

    .EXAMPLE

        Get-VMConsoleURL -VMName "Embedded-VCSA1"

#>

    param(

        [Parameter(Mandatory=$true)][String]$VMName

         )

    Function Get-SSLThumbprint {

        param(

        [Parameter(

            Position=0,

            Mandatory=$true,

            ValueFromPipeline=$true,

            ValueFromPipelineByPropertyName=$true)

        ]

        [Alias('FullName')]

        [String]$URL

        )

        add-type @"

            using System.Net;

            using System.Security.Cryptography.X509Certificates;

                public class IDontCarePolicy : ICertificatePolicy {

                public IDontCarePolicy() {}

                public bool CheckValidationResult(

                    ServicePoint sPoint, X509Certificate cert,

                    WebRequest wRequest, int certProb) {

                    return true;

                }

                }

"@

        [System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy

        # Need to connect using simple GET operation for this to work

        Invoke-RestMethod -Uri $URL -Method Get | Out-Null

        $ENDPOINT_REQUEST = [System.Net.Webrequest]::Create("$URL")

        $SSL_THUMBPRINT = $ENDPOINT_REQUEST.ServicePoint.Certificate.GetCertHashString()

        return $SSL_THUMBPRINT -replace '(..(?!$))','$1:'

    }

   $VM = Get-VM -Name $VMName

   $VMMoref = $VM.ExtensionData.MoRef.Value

   $VCInstasnceUUIDOriginal = $global:DefaultVIServer.InstanceUuid

   $VCInstasnceUUID = $VCInstasnceUUIDOriginal.ToUpper()

   $VCName = $global:DefaultVIServer.Name

   $SessionMgr = Get-View $DefaultViserver.ExtensionData.Content.SessionManager

   $Ticket = $SessionMgr.AcquireCloneTicket()

   $VCSSLThumbprint = Get-SSLThumbprint "https://$VCname"

   $URL = "https://$VCName/ui/#?extensionId=vsphere.core.inventory.serverObjectViewsExtension&objectId=urn:vmom..."

   $URL

$VM = Get-VM -Name $VMName

   $VMMoref = $VM.ExtensionData.MoRef.Value

   $VCInstasnceUUIDOriginal = $global:DefaultVIServer.InstanceUuid

   $VCInstasnceUUID = $VCInstasnceUUIDOriginal.ToUpper()

   $VCName = $global:DefaultVIServer.Name

   $SessionMgr = Get-View $DefaultViserver.ExtensionData.Content.SessionManager

   $Ticket = $SessionMgr.AcquireCloneTicket()

   $VCSSLThumbprint = Get-SSLThumbprint "https://$VCname"

   $URL = "https://$VCName/ui/#?extensionId=vsphere.core.inventory.serverObjectViewsExtension&objectId=urn:vmom..."

   $URL

}

}

I hope it will help you. 🙂

Reply
0 Kudos