VMware Cloud Community
wglo5
Contributor
Contributor
Jump to solution

Open a VM console automatically when logging into ESXi 6.5 host client

I would like to make access to one of the VMs on my host as simple as possible for our end users.  I would like for them to be presented with the VM console when they log into the host client rather than them having to select the VM from the inventory and selecting to open the console.

I have created a user/role which only gives them interact privileges so when they log in they only have the required VM listed but does anyone know how to automate the process of starting the VM console?

In short, I would like to have a desktop shortcut on my client machine which takes the user straight into the VM console.  Any ideas?

1 Solution

Accepted Solutions
PabloJAguilar20
Enthusiast
Enthusiast
Jump to solution

Hellos.

Yes, You can use VMware Remote Console for that.

I give u these links for information and download

VMware Remote Console Guide for vSphere PDF: https://www.vmware.com/pdf/desktop/vmware-remote-console-100-vsphere.pdf

Download: https://my.vmware.com/group/vmware/details?downloadGroup=VMRC10.0.2&productId=614

I hope that help you

Regards!!

Pablo J Aguilar Consultor de Infraestructuras Virtuales. Buenos Aires - Argentina

View solution in original post

0 Kudos
2 Replies
PabloJAguilar20
Enthusiast
Enthusiast
Jump to solution

Hellos.

Yes, You can use VMware Remote Console for that.

I give u these links for information and download

VMware Remote Console Guide for vSphere PDF: https://www.vmware.com/pdf/desktop/vmware-remote-console-100-vsphere.pdf

Download: https://my.vmware.com/group/vmware/details?downloadGroup=VMRC10.0.2&productId=614

I hope that help you

Regards!!

Pablo J Aguilar Consultor de Infraestructuras Virtuales. Buenos Aires - Argentina
0 Kudos
MBreidenbach0
Hot Shot
Hot Shot
Jump to solution

PowerCLI can launch VMRC (Get-VM vmname | Open-VMConsoleWindow) so you can run a script which launches VMRC for a VM.

Edit: Since I wanted to play with PowerShell + GUI I grabbed some scripts from Microsoft PowerShell blogs and used that to make a GUI frontend - connects to vcenter, gets a list of VMs, shows that list in a GUI window and launches VMRC for selected VMs. Most probably can be improved. No warranties - it works for me.

(The replica and nea parameters hide VMs of a Veeam Cloud Connect lab environment)

RunVMRC.ps1:

<#

    .SYNOPSIS

    Shows MultiListBox of connected VMs then launches VMRC for selected VMs

    .DESCRIPTION

    If not connected to a VIserver asks for VIserver name and connects

Shows MultiListBox of connected VMs then launches VMRC for selected VMs

.EXAMPLE

    VMRC

.PARAMETER VM

    open console for VM; don't show selection box

    .PARAMETER VIserver

    Name of vCenter Server

.PARAMETER AskVIServer

Show VIServer name popup

    .PARAMETER replica

    show/ignore *_replica VMs

    .PARAMETER nea

    show/ignore Veeam Network Extension Appliance* VMs

    .NOTES

some stuff Martin Breidenbach 2017

lots of stuff grabbed from internet

#>

#Requires -Modules VMware.VimAutomation.Core

param(

[Parameter(Mandatory=$False)]

[string]$VM,

[Parameter(Mandatory=$False)]

[string]$VIServer="vcenter.domain.com",

[Parameter(Mandatory=$False)]

[boolean]$AskVIServer=$false,

[Parameter(Mandatory=$False)]

[boolean]$replica=$false,

[Parameter(Mandatory=$False)]

[boolean]$nea=$false

) #param

function Show-MultiListbox {

<#

.SYNOPSIS

Displays a MultiListBox

.DESCRIPTION

Displays a MultiListBox

.EXAMPLE

$SelectedVMs = Show-MultiListBox $VMs -Title1 'Run VMRC' -Title2 'Please select VMs from the list below:' -Height 300

.PARAMETER List

list of strings

.PARAMETER Title1

sets MultiListBox Title

.PARAMETER Title2

sets MultiListBox Text

.PARAMETER Height

sets MultiListBox Height

.PARAMETER help

calls GET-HELP

.NOTES

based on MultiListBox: https://technet.microsoft.com/en-us/library/ff730950.aspx

based on https://blogs.technet.microsoft.com/heyscriptingguy/2014/08/02/weekend-scripter-fixing-powershell-gu...

modified by Martin Breidenbach 2017

#>

Param (

[Parameter(Mandatory=$True,Position=1)]

[string[]]$List,

[Parameter(Mandatory=$False)]

[string]$Title1='MultiListBox',

[Parameter(Mandatory=$False)]

[string]$Title2='Please select item(s) from list:',

[Parameter(Mandatory=$False)]

[int]$Height=200,

[Parameter(Mandatory=$False)]

[switch]$help

)

process {

if($help) {Get-Help $MyInvocation.MyCommand.Name; break}

Add-Type -AssemblyName System.Windows.Forms

Add-Type -AssemblyName System.Drawing

# Form

$objForm                  = New-Object System.Windows.Forms.Form

$objForm.Text             = $Title1

$objForm.Size             = New-Object System.Drawing.Size(300,($Height + 120))

$objForm.StartPosition    = "CenterScreen"

$objForm.Icon             = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")

$objForm.minimumSize      = New-Object System.Drawing.Size(200,160)

# OK Button

$OKButton                 = New-Object System.Windows.Forms.Button

$OKButton.Location        = New-Object System.Drawing.Size(75,($Height + 40))

$OKButton.Size            = New-Object System.Drawing.Size(75,23)

$OKButton.Text            = "OK"

$OKButton.DialogResult    = [System.Windows.Forms.DialogResult]::OK

$objForm.AcceptButton     = $OKButton

$objForm.Controls.Add($OKButton)

# Cancel Button

$CancelButton              = New-Object System.Windows.Forms.Button

$CancelButton.Location     = New-Object System.Drawing.Size(150,($Height + 40))

$CancelButton.Size         = New-Object System.Drawing.Size(75,23)

$CancelButton.Text         = "Cancel"

$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel

$objForm.CancelButton      = $CancelButton

$objForm.Controls.Add($CancelButton)

# Label

$objLabel                 = New-Object System.Windows.Forms.Label

$objLabel.Location        = New-Object System.Drawing.Size(10,20)

$objLabel.Size            = New-Object System.Drawing.Size(280,20)

$objLabel.Text            = $Title2

$objForm.Controls.Add($objLabel)

# Listbox

$objListbox               = New-Object System.Windows.Forms.Listbox

$objListbox.Location      = New-Object System.Drawing.Size(10,40)

$objListbox.Size          = New-Object System.Drawing.Size(260,$Height)

$objListbox.SelectionMode = "MultiExtended"

ForEach ($Item in $List) {

[void]$objListBox.Items.Add($Item)

}

$objForm.Controls.Add($objListbox)

$objForm.Topmost = $True

$resizeHandler = {

$objListbox.Size       = New-Object System.Drawing.Size(($objForm.Width - 40),($objForm.Height - 120))

$OKButton.Location     = New-Object System.Drawing.Size(($objForm.Width/2-75),($objForm.Height -  80))

$CancelButton.Location = New-Object System.Drawing.Size(($objForm.Width/2)   ,($objForm.Height -  80))

}

$objForm.Add_Resize($resizeHandler)

# Show Form

$objForm.Add_Shown({$objForm.Activate()})

$Result = $objForm.ShowDialog()

if ($Result -eq [System.Windows.Forms.DialogResult]::OK) {

Return $objListBox.SelectedItems

}

} #process

}

function Show-InputBox {

<#

.SYNOPSIS

Displays a InputBox

.DESCRIPTION

Displays a InputBox

.EXAMPLE

Show-InputBox "edit me"

.PARAMETER Text

input string

.PARAMETER Title1

sets InputBox Title

.PARAMETER Title2

sets InputBox Text

.NOTES

based on https://technet.microsoft.com/en-us/library/ff730941.aspx

based on https://blogs.technet.microsoft.com/heyscriptingguy/2014/08/02/weekend-scripter-fixing-powershell-gu...

modified by Martin Breidenbach 2017

#>

Param (

[Parameter(Mandatory=$True,Position=1)]

[string]$Text,

[Parameter(Mandatory=$False)]

[string]$Title1='Data Entry Form',

[Parameter(Mandatory=$False)]

[string]$Title2='Please enter the information in the space below:'

)

process {

Add-Type -AssemblyName System.Windows.Forms

Add-Type -AssemblyName System.Drawing

$objForm               = New-Object System.Windows.Forms.Form

$objForm.Text          = $Title1

$objForm.Size          = New-Object System.Drawing.Size(300,160)

$objForm.StartPosition = "CenterScreen"

$objForm.Icon          = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")

$objForm.minimumSize   = New-Object System.Drawing.Size(200,160)

$objForm.maximumSize   = New-Object System.Drawing.Size(965,160)

$objForm.MinimizeBox   = $false

$objForm.MaximizeBox   = $false

$OKButton              = New-Object System.Windows.Forms.Button

$OKButton.Location     = New-Object System.Drawing.Size(75,80)

$OKButton.Size         = New-Object System.Drawing.Size(75,23)

$OKButton.Text         = "OK"

$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK

$objForm.AcceptButton  = $OKButton

$objForm.Controls.Add($OKButton)

$CancelButton              = New-Object System.Windows.Forms.Button

$CancelButton.Location     = New-Object System.Drawing.Size(150,80)

$CancelButton.Size         = New-Object System.Drawing.Size(75,23)

$CancelButton.Text         = "Cancel"

$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel

$objForm.CancelButton      = $CancelButton

$objForm.Controls.Add($CancelButton)

$objLabel          = New-Object System.Windows.Forms.Label

$objLabel.Location = New-Object System.Drawing.Size(10,20)

$objLabel.Size     = New-Object System.Drawing.Size(280,20)

$objLabel.Text     = $Title2

$objForm.Controls.Add($objLabel)

$objTextBox          = New-Object System.Windows.Forms.TextBox

$objTextBox.Location = New-Object System.Drawing.Size(10,40)

$objTextBox.Size     = New-Object System.Drawing.Size(260,20)

$objTextBox.Text     = $Text

$objForm.Controls.Add($objTextBox)

$objForm.Topmost = $True

$resizeHandler = {

$objTextBox.Size       = New-Object System.Drawing.Size(($objForm.Width - 40),20)

$OKButton.Location     = New-Object System.Drawing.Size(($objForm.Width/2-75),($objForm.Height - 80))

$CancelButton.Location = New-Object System.Drawing.Size(($objForm.Width/2)   ,($objForm.Height - 80))

}

$objForm.Add_Resize($resizeHandler)

$objForm.Add_Shown({$objForm.Activate()})

$Result = $objForm.ShowDialog()

if ($Result -eq [System.Windows.Forms.DialogResult]::OK) {

Return $objTextBox.Text

}

} #process

}

function Show-MessageBox {

<#

.SYNOPSIS

Displays a MessageBox

.DESCRIPTION

Displays a MessageBox

.EXAMPLE

Show-MessageBox -Title 'WARNING' -Message 'There was an error'

.PARAMETER Title

sets MessageBox Title

.PARAMETER Message

sets MessageBox Text

.NOTES

based on https://technet.microsoft.com/en-us/library/ff730941.aspx

based on https://blogs.technet.microsoft.com/heyscriptingguy/2014/08/02/weekend-scripter-fixing-powershell-gu...

modified by Martin Breidenbach 2017

#>

Param (

[Parameter(Mandatory=$True,Position=1)]

[string]$Title='Message',

[Parameter(Mandatory=$False)]

[string]$Message='This is the message!'

)

process {

Add-Type -AssemblyName System.Windows.Forms

Add-Type -AssemblyName System.Drawing

$width = [math]::max($Title.Length,$Message.Length)*6

$objForm               = New-Object System.Windows.Forms.Form

$objForm.Text          = $Title

$objForm.Size          = New-Object System.Drawing.Size(($width+40),130)

$objForm.StartPosition = "CenterScreen"

$objForm.Icon          = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe")

$objForm.minimumSize   = New-Object System.Drawing.Size(100,130)

$objForm.maximumSize   = New-Object System.Drawing.Size(900,130)

$objForm.MinimizeBox   = $false

$objForm.MaximizeBox   = $false

$objForm.KeyPreview = $True

$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$objForm.Close()}})

$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}})

$OKButton              = New-Object System.Windows.Forms.Button

$OKButton.Location     = New-Object System.Drawing.Size($objForm.Width/2-50),($objForm.Height - 80)

$OKButton.Size         = New-Object System.Drawing.Size(75,23)

$OKButton.Text         = "OK"

$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK

$objForm.AcceptButton  = $OKButton

$objForm.Controls.Add($OKButton)

$objLabel          = New-Object System.Windows.Forms.Label

$objLabel.Location = New-Object System.Drawing.Size(10,20)

$objLabel.Size     = New-Object System.Drawing.Size($width,20)

$objLabel.Text     = $Message

$objForm.Controls.Add($objLabel)

$objForm.Topmost = $True

$resizeHandler = {

$OKButton.Location = New-Object System.Drawing.Size(($objForm.Width/2-50),($objForm.Height - 80))

}

$objForm.Add_Resize($resizeHandler)

$objForm.Add_Shown({$objForm.Activate()})

[void] $objForm.ShowDialog()

} #process

}

# Check that we are connected to a VIServer

if (-not $global:DefaultVIServers) {

if ($AskVIServer) {$VIServer = Show-InputBox $VIServer -Title1 "Run VMRC" -Title2 "Enter vCenter Server:"}

if ($VIServer) {Connect-VIServer $VIServer}

if (-not $global:DefaultVIServers) {Show-MessageBox -Title 'Warning:' -Message 'VMRC: You are not connected to any VIServer'; break}

}

# Get sorted list of connected VM names

if ($VM) {

$Exists = Get-VM -name $VM -ErrorAction SilentlyContinue

if ($Exists) {

$SelectedVMs = $VM

} else {

Show-MessageBox -Title 'Warning:' -Message "VMRC: VM $VM not found"; break

}

} else {

$VMs = (Get-VM | Where-Object{$_.ExtensionData.Runtime.ConnectionState -eq 'connected'}).Name | Sort-Object

if (-not $replica) {$VMs = ($VMs | where-object {-not($_ -like '*_replica')})}

if (-not $nea)     {$VMs = ($VMs | where-object {-not($_ -like 'Network Extension Appliance*')})}

# select VMs

$SelectedVMs = Show-MultiListBox $VMs -Title1 'Run VMRC' -Title2 'Please select VMs from the list below:' -Height 300

}

# run VMRC for selected VMs

if ($SelectedVMs) {

ForEach ($VM in $SelectedVMs) {Open-VMConsoleWindow(Get-VM($VM))}

} else {

Show-MessageBox -Title 'Warning:' -Message 'VMRC: No VMs have been selected.'; break

}