06 November 2026

Create a listening port on Windows

To get PowerShell to start listening on e.g. port 2500 - useful for testing network connectivity to that port:

($listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Any, 2500)).Start()

For older PowerShell versions:

$listener = New-Object System.Net.Sockets.TcpListener([System.Net.IPAddress]::Any, 2500); $listener.Start()

And to stop listening:

$listener.Stop()

No comments:

Post a Comment