Automation

 View Only
  • 1.  Change pipe on serial port

    Posted Dec 01, 2023 02:11 PM

    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.

     



  • 2.  RE: Change pipe on serial port
    Best Answer

    Posted Dec 01, 2023 06:09 PM

    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)
    


  • 3.  RE: Change pipe on serial port

    Posted Dec 04, 2023 12:26 PM

    Great, many thanks!