dmini
Enthusiast
Enthusiast

adding serial port

Jump to solution

I'm trying to add a serial port to a vm to point to the ESXI hosts physical serial port. I have to repeat this about a hundred times, so looking to script this. I can find scripts for doing this with other types of serial ports, but been unable to adapt this to a physical serial port mapped through.

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Can you try like this ?

You will have to check the "devicename"

$vmName = <guestname>

$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.VirtualSerialPortDeviceBackingInfo

$dev.device.backing.deviceName = '/dev/char/serial/uart0'

$dev.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo

$dev.device.connectable.startConnected = $true

$dev.device.connectable.allowGuestControl = $true

$dev.device.connectable.connected = $true

$dev.device.yieldOnPoll = $true

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.DeviceChange += $dev

$vm = Get-VM -Name $vmName

$vm.ExtensionData.ReconfigVM($spec)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

Can you try like this ?

You will have to check the "devicename"

$vmName = <guestname>

$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.VirtualSerialPortDeviceBackingInfo

$dev.device.backing.deviceName = '/dev/char/serial/uart0'

$dev.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo

$dev.device.connectable.startConnected = $true

$dev.device.connectable.allowGuestControl = $true

$dev.device.connectable.connected = $true

$dev.device.yieldOnPoll = $true

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$spec.DeviceChange += $dev

$vm = Get-VM -Name $vmName

$vm.ExtensionData.ReconfigVM($spec)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
dmini
Enthusiast
Enthusiast

Thank you SO MUCH!!

I struggled with the syntax - haven't got my head around these registry type settings at all!

Debbie

0 Kudos