You cannot generate the remote console URL for the VMs using the VI SDK. You would need to use the web access to do so.
Any guidance on doing it that way?
In .NET/C# that is Console.WriteLine(Encoding.ASCII.GetString(Convert.FromBase64String(b642text)));
So for the opposite you could just work backwords and generate a base64 string that covers you.
Looking at a couple examples I did to confirm this was the core of the wsUrl is "wsUrl=https://localhost/sdk?vmId=VirtualMachine|vm-9999&ui=36"
So you would just need to update the "vm-9999" w the moref id from VI SDK. The ui (I think) is the integer generated from the sum of the checkboxes you see in the ui. false/false = 0, true/false = 4 + 8, false/true = 1 + 32, true/true = 4 + 32 (36 is what I used)
So using the vm moref id and your "ui" selection you can genenratethe URL on demand. Build your string, encode to base64, append an underscore "_" to the end of the b64 string, take that whole chunk and append that to your VCs "https://<vc URL>/ui/vmDirect.do?view=" URL which will look like it was generated from the console UI.
Hope this helps and hope that it doesn't get swatted by the mods.
What I have encoded is "wsUrl=http://localhost:8085&vmId=VirtualMachine|1040&ui=36". From VI SDK, the moref of vm is vm-78, but what I get is 1040. Do you have any idea how to get 1040? Thanks for your help.
We are thinking of having a VirtualCenter for each customer we support, and so the other day I made a Perl script to generate remote consoles for the VMs so the OS admins wouldn't have to keep track of what VM is on what VC. I've attached a stripped down version of the script. It just prints an HTML link to the VM. If this works for you, you should be able modify it. Hope it helps.
bombpop: Thanks for uploading the script, however I am having trouble using the same, I get the below output when I execute the same, I was wondering if you could help me to figure out how to fix this..
C:\Documents and Settings\*******\Desktop\vmware>generate_remote_console.pl --server 10.31.78.147 --username administrator --password ********
<a href="https://10.31.78.147/ui/vmDirect.do?view=d3NVcmw9aHR0cDovL2xvY2FsaG9zdC9zZGsmdm1JZD1WaXJ0dWFsTWFjaGluZXx2bS0yMzcmdWk9MzM=_">marga-win2k3</a><br /><a hr
ef="https://10.31.78.147/ui/vmDirect.do?view=d3NVcmw9aHR0cDovL2xvY2FsaG9zdC9zZGsmdm1JZD1WaXJ0dWFsTWFjaGluZXx2bS0zNjQmdWk9MzM=_">marga-win2k3</a><br /><a href="h
ttps://10.31.78.147/ui/vmDirect.do?view=d3NVcmw9aHR0cDovL2xvY2FsaG9zdC9zZGsmdm1JZD1WaXJ0dWFsTWFjaGluZXx2bS00MTImdWk9MzM=_">vTest</a><br /><a href="https://10.31
.78.147/ui/vmDirect.do?view=d3NVcmw9aHR0cDovL2xvY2FsaG9zdC9zZGsmdm1JZD1WaXJ0dWFsTWFjaGluZXx2bS0xNTYmdWk9MzM=_">Win2k3-Test</a><br /><a href="https://10.31.78.14
C:\Documents and Settings\********\Desktop\vmware>
I presume I need to use https://10.31.78.147/ui/vmDirect.do?view=d3NVcmw9aHR0cDovL2xvY2FsaG9zdC9zZGsmdm1JZD1WaXJ0dWFsTWFjaGluZXx2bS0yMzcmdWk9MzM=_ for the VM named marga-win2k3, but it doesn't work.
Any help would be greatly appreciated.
Here is a Perl script that'll generate the proper remote console URL for a VM: generateVMRemoteConsoleURL.pl
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
If you find this information useful, please award points for "correct" or "helpful".
fantastic, it works like charme, thanks a lot lamw.
How did you run this ? from a Windows or Linux computer.. Can you send me the exact syntax that use.. I am having trouble running this
Can you run it against a vcenter or you have to run it for a each individual VM