Wednesday, 23 March 2016

A simple TCP listener in PowerShell

Sometimes you have to make a point. Today my point was: “If you do THIS on the firewall, I can connect from server A, B and C to THAT on server D.”

Unfortunately THAT was not yet installed on server D, but I wanted to have a successful test. Therefore I needed to have something on server D that is listening on the same port like THAT.
Since one can use .NET Framework classes from within Windows PowerShell it is possible to write a script which starts a TcpListener server and simulates that on server D THAT missing piece is already installed.

Just invoke the script with the parameters:
PS C:\Users\daniel\Desktop> .\Start-TcpListener.ps1 -IpAddress 127.0.0.1 -TcpPort 9090

And this is the script:

No comments:

Post a Comment