Skip to content

Instantly share code, notes, and snippets.

@bortels
Created December 11, 2013 01:26
Show Gist options
  • Save bortels/7903570 to your computer and use it in GitHub Desktop.
Save bortels/7903570 to your computer and use it in GitHub Desktop.
Open Remote VMWare Console in powershell
# Based on http://sourceforge.net/p/vghetto/code/HEAD/tree/scripts/generateHTML5VMConsole.pl#l54
# Requires Openssl - get it from http://www.openssl.org/related/binaries.html
$openssl = "C:\OpenSSL-Win64\bin\openssl.exe"
$vm = get-vm -name "canary"
# Get the session associated with the vcenter this VM is on. Ugly Hack.
# /[email protected]:443/VirtualMachine=VirtualMachine-vm-804/
$uid = $vm.uid
($junk, $fqdn) = $uid.split('@')
($fqdn, $junk) = $fqdn.split(':')
$session = get-view sessionmanager -server $fqdn
$ticket = $session.AcquireCloneTicket()
$mo_ref = (Get-view -VIObject $vm).MoRef
# now we have to get the thumbprint of the webserver. Easy? no. Sigh.
#---
$url = "http://" + $server + ":7331/console/" +
"?vmId=" + $dict['vmid'] +
"&vmName=" + $dict['vmName'] +
"&host=" + $destvc +
"&sessionTicket=" + $dict['ticket'] +
"&thumbprint=" + $dict['thumbprint']
$url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment