VMware Cloud Community
firthmj2
Contributor
Contributor
Jump to solution

Change pipe on serial port

It is possible to add serial ports to a VM using the process described in this post:

Configuring Serial Ports

However, I would like to update which pipe name an existing serial port is connected to from PowerCLI.

Does someone have a process for doing that?

Presumably I need to somehow get the existing serial port objects on a VM, and then update the "Backing.PipeName" setting for the one I want to change (and then maybe apply that change).

But I'm not exactly sure the steps I will need.

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

If you just want to change the Pipename, you can do something like this

$vmName = 'MyVM'
$oldPipeName = 'oldPipeName'
$newPipeName = 'newPipeName'

$vm = Get-VM -Name $vmName
$serial = $vm.ExtensionData.Config.Hardware.Device.where{ $_ -is [VMware.Vim.VirtualSerialPort] -and $_.Backing.PipeName -eq $oldPipeName }

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$dev =  New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit
$dev.Device = $serial[0]
$dev.Device.Backing.PipeName = $newPipeName
$spec.DeviceChange += $dev

$vm.ExtensionData.ReconfigVM($spec)


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

If you just want to change the Pipename, you can do something like this

$vmName = 'MyVM'
$oldPipeName = 'oldPipeName'
$newPipeName = 'newPipeName'

$vm = Get-VM -Name $vmName
$serial = $vm.ExtensionData.Config.Hardware.Device.where{ $_ -is [VMware.Vim.VirtualSerialPort] -and $_.Backing.PipeName -eq $oldPipeName }

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$dev =  New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.Operation = [VMware.Vim.VirtualDeviceConfigSpecOperation]::edit
$dev.Device = $serial[0]
$dev.Device.Backing.PipeName = $newPipeName
$spec.DeviceChange += $dev

$vm.ExtensionData.ReconfigVM($spec)


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

firthmj2
Contributor
Contributor
Jump to solution

Great, many thanks!

Reply
0 Kudos