Goto ESXi host on vCenter ->Configuration -> Security Profile ->Firewall Properties.
The Goto VM where you want to enable the serial connection à
Right click -> Edit Settings -> Hardware -> Add -> Serial Port
Reference:
PowerCLI script to do create serial port. Although Firewall settings on esxi server has to be done manually.
# Adds the base cmdlets
Add-PSSnapin VMware.VimAutomation.Core
# This script adds some helper functions and sets the appearance. You can pick and choose parts of this file for a fully custom appearance.
. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
Function New-SerialPort
{
Param(
[string]$vmName,
[string]$prt
) #end
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.operation = "add"
$dev.device = New-Object VMware.Vim.VirtualSerialPort
$dev.device.key = -1
$dev.device.backing = New-Object VMware.Vim.VirtualSerialPortURIBackingInfo
$dev.device.backing.direction = "server"
$dev.device.backing.serviceURI = "telnet://:$prt"
$dev.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$dev.device.connectable.connected = $true
$dev.device.connectable.StartConnected = $true
$dev.device.yieldOnPoll = $true
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.DeviceChange += $dev
$vm = Get-VM -Name $vmName
$vm.ExtensionData.ReconfigVM($spec)
}
- Power OFF your VM
- open PowerCLI
- New-SerialPort <vmname> <telnet port number>
- Power ON your vm
- telnet <esxi IP> <port number>