PowerShell TCP Listener


PowerShell uses the following commands to open a socket on a specific port via System.NET:

$endpoint = new-object System.Net.IPEndpoint([ipaddress]::any,80)
$listener = new-object System.Net.Sockets.TcpListener $endpoint
$data = $listener.AcceptTcpClient()

The commands can be used for simulating a network service, as an example to test the network connection before the actual network service is installed, see also: PING with Port - Windows cmd | PowerShell: Test-Netconnection

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-08-12 from Bernhard | Übersetzung Deutsch |🔔 | Comments:0

PowerShell: Read Active Directory data | PowerShell | Send PowerShell Email: Send-MailMessage

Top articles in this section

PowerShell Log-Files: Logging into a textfile - write to file

Log files in PowerShell can be created via the Out-File command, via a custom function, or via PowerShell's built-in Transcript.

PowerShell: Prevent screen saver, lock: Move mouse regularly

Alternatively, if you can't change the screen lock settings, you can move the mouse regularly, or have a script move the mouse. Originally published as an AutoIt script, I recreated the script with a few PowerShell lines. Anyone who copies the following commands into a PowerShell session will prevent the computer from locking the screen or starting the screensaver:

PowerShell: File attributes: Change date - without any tools.

As an alternative to special programs, the date of a file or folder can also be changed with PowerShell. 

Questions / Comments