Generate List of Remote Console URLs for vCenter 5.0 Through PowerCLI

Posted: December 10, 2012 in Scripts, VMware

There have been a few posts around generating the direct console URLs for VMs and they all seem to use Perl. Based on the info from these posts, I have created this cut back PowerCLI version. Only tested with vCenter 5.0 and outputs to a CSV file for every VM in the environment.

Be sure to change the output location and vCenter name.

$CSVOutPut = "C:\Support\ConsoleLinks.csv"
If (Test-Path $CSVOutPut) { Remove-Item $CSVOutPut }

$Creds = Get-Credential
$vcName = ""

$UUID = ((Connect-VIServer $vcName -Credential $Creds).InstanceUUID).ToUpper()

$VMs = Get-VM

ForEach ($VM in $VMs){

$MoRef = $VM.ExtensionData.MoRef.Value
$ConsoleLink = "https://" + $vcName + ":9443/vsphere-client/vmrc/vmrc.jsp?vm=" + $UUID + ":VirtualMachine:" + $MoRef
$VM.Name + "," + $ConsoleLink | Out-File $CSVOutPut -Append


Disconnect-VIServer $vcName -Confirm:$False

  1. suechti says:

    Get-VIServer is not known by PowerCLI, is your script correct here?
    Did you mean Connect-VIServer?
    The generated links won´t Work, MoRef is empty.

    Your Solution sounds fine, i need something like that 🙂
    Thanks and best regards

Leave a Reply

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

You are commenting using your 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