NetworkConnection
Initiate a client-server communication channel using PowerShell
Install / Use
/learn @PanosGreg/NetworkConnectionREADME
NetworkConnection
Initiate a client-server communication channel using PowerShell
Disclaimer
This is an old module I wrote back in 2019, so the code is not as savvy.
It can get some improvements in regards to clean code, readability, error-handling, SRP, KISS, .Net types with C#, etc...
But the functions work nonetheless, it does what it's supposed to do.
Also the Pester tests were written for Pester v4, so they won't work with Pester v5, they need to be updated.
I may spend a bit of time on the module at some stage if I have a break, we'll see.
Since this was an old module that I happened to restore from my computer, I've also added an extra folder with my notes from back then, as they are handy and give some context, even though they are not needed for the module to work.
Examples
TCP Example
- Open 2 powershell sessions, one will be the server and the other one will be the client
first we'll set up a new client-server connection, we'll use the TCP transport for this one
-
On the server
$con = Start-ServerConnection -Transport TCP -PortNumber 1202 -Timeout 30 -Verbose
let's say your local IP is 192.168.0.52 -
And now on the client
$con = Start-ClientConnection -ComputerName 192.168.0.52 -Transport TCP -PortNumber 1202 -Verbose
now let's send some data over the connection
- From either the server or the client
SendTo-NetworkConnection -Connection $con -Data 'abcd' - And then on the other end
ReceiveFrom-NetworkConnection -Connection $con
finally let's close the connection
- From both the server and the client
Stop-NetworkConnection -Connection $con -Verbose
Names Pipes Example
same setup as above, 2 PS Sessions
- On the server:
$con = Start-ServerConnection -Transport Pipes -PipeName MyConnection -Timeout 30 -Verbose - On the client:
$con = Start-ClientConnection -ComputerName 192.168.0.52 -Transport Pipes -PipeName MyConnection -Verbose - From either end:
SendTo-NetworkConnection -Connection $con -Data '1234' - On the other end:
ReceiveFrom-NetworkConnection -Connection $con - From both ends:
Stop-NetworkConnection -Connection $con -Verbose
UDP Example
again same setup
- On the server:
$con = Start-ServerConnection -Transport UDP -PortNumber 1202 -Timeout 30 -Verbose - On the client:
$con = Start-ClientConnection -ComputerName 192.168.0.52 -Transport UDP -PortNumber 1202 -Verbose - From either end:
SendTo-NetworkConnection -Connection $con -Data 'qqqq' - On the other end:
ReceiveFrom-NetworkConnection -Connection $con - From both ends:
Stop-NetworkConnection -Connection $con -Verbose
HTTP Example
the only change on this setup, is that the PS Session on the server side needs to run as admin
- On the server:
$con = Start-ServerConnection -Transport HTTP -PortNumber 1202 -Timeout 30 -Verbose - On the client:
$con = Start-ClientConnection -ComputerName 192.168.0.52 -Transport HTTP -PortNumber 1202 -Verbose - From either end:
SendTo-NetworkConnection -Connection $con -Data 'test12' - On the other end:
ReceiveFrom-NetworkConnection -Connection $con - From server end:
Stop-NetworkConnection -Connection $con -Verbose
no need to stop the connection from the client side when using the HTTP transport
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
