Get-ConsoleURL

VMware’s PowerCLI is probably the most used tool on any of my computers outside of a web browser. They are continuing to improve upon the product that basically saved powershells life (my personal opinion). With that said, I am constantly building little functions, modules, scripts to perform simple tasks.

I’ll be leaving as much of my work on my personal GitHub workspace. Feel free to check it out.

So, Get-ConsoleURL what is it? As you would imagine, its a simple function that returns the URL of a VM’s web console. Why is this important? Well wouldn’t it be nice to quickly share this with a co-worker? Or save this URL in a custom app/webpage you have? The Open-VMConsoleWindow function is very useful in a local machine, but it requires Powercli and opens a local copy of the vmrc. This function I have created will give you a shareable link to the vCenter and reference the vm via the MoRef.

Check out my function here (Get-ConsoleURL).

Example usage:

Get-ConsoleURL -vmName $vmName -vCenterUN $username -vCenterPW $password

Differences in return:

Open-VMConsoleWindow -UrlOnly -vm $vm

file:///C:\Program%20Files%20(x86)\VMware\Infrastructure\vSphere%20PowerCLI\VMConsoleWindow\VMConsoleWindow.html?host=<vcenter>&vmid=vm-32&vmName=<vm>&ticket=cst-VCT-52c82763-13b8-cc54-2cbf-ee726cfbd5b8--tp-B9-A6-19-C3-54-5F-34-4F-FF-06-99-29-74-0A-CD-70-AA-82-74-96&tunnelConnection=0

Get-ConsoleURL -vmname $vm

https://<vcenter>:9443/vsphere-client/webconsole.html?vmId=vm-32&vmName=<vm>&serverGuid=&host=<host>&sessionTicket=cst-VCT-529f6e91-8f95-6f1d-11c6-7765ee2202f4--tp-B9-A6-19-C3-54-5F-34-4F-FF-06-99-29-74-0A-CD-70-AA-82-74-96&thumbprint=5A:AB:D4:75:29:E8:D5:94:09:8F:D2:91:CF:DC:AB:C0:69:03:37:42

 

I have a few issues open to add some functionality as well as improve the error handling.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s