Created
January 11, 2020 16:16
-
-
Save TrooperT/52776ffa2d559a4b37fbd7915dd1ed69 to your computer and use it in GitHub Desktop.
Revisions
-
TrooperT created this gist
Jan 11, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ Function New-SerialPort { Param ( [Parameter(Mandatory=$True,ValueFromPipelinebyPropertyName=$True)] $Name, [Parameter(Mandatory=$True,ValueFromPipelinebyPropertyName=$True)] $Port ) Process { $VMDevSpec = New-Object VMware.Vim.VirtualDeviceConfigSpec $VMDevSpec.Operation = "add" $VMDevSpec.device = New-Object VMware.Vim.VirtualSerialPort $VMDevSpec.device.key = -1 $VMDevSpec.device.backing = New-Object VMware.Vim.VirtualSerialPortURIBackingInfo $VMDevSpec.device.backing.direction = "server" $VMDevSpec.device.backing.serviceURI = "telnet://:$Port" $VMDevSpec.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo $VMDevSpec.device.connectable.connected = $true $VMDevSpec.device.connectable.StartConnected = $true $VMDevSpec.device.yieldOnPoll = $true $VMSpec = New-Object VMware.Vim.VirtualMachineConfigSpec $VMSpec.DeviceChange += $VMDevSpec $VM = Get-VM -Name $Name $VM.ExtensionData.ReconfigVM_Task($VMSpec) } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ Get-VM -Name cli | New-SerialPort -port 5555