How can I connect to a cisco switch via serial console cable from powershell?

I don't actually need to perform any operations on the switch. I just need to verify it's there.

I have some remote servers that I need to verify have the blue serial console cable hooked up correctly. Rather than RDC into each of them and copy/configure putty just to hit enter a couple times, I'd like to use "enter-pssession" to remotely connect to PowerShell and access COM1 that way.

I've tried using this, but get no feedback on the console.

https://blogs.msdn.microsoft.com/powershell/2006/08/31/writing-and-reading-info-from-serial-ports/

Thanks!


Solution 1:

Figured it out. Slap enter-pssession -computername XXXXXXX in front of this to remotely connect to a system to check.

$com = New-Object System.IO.Ports.SerialPort(“COM1”)
$com.open()
$com.write([char]13)
$com.ReadExisting()