Powershell

[Powershell] – UDP connexion with Net.UDPClient

Click to rate this post!
[Total: 0 Average: 0]

Powershell – how to make an UDP connection ?
How to use System.Net.Sockets.UDPClient ?


Here a powershell script to connect to an UDP port on a host (localhost or remote). 

Useful for checking the proper functioning of a firewall. the connection script on port tcp in question uses the object System.Net.Sockets.UdpClient


the connection script on UDP port in question uses the object System.Net.Sockets.UdpClient

$ip = “192.168.0.1”
$port
= “161”
$connection = New-Object -TypeName System.Net.Sockets.UdpClient -ArgumentList $ip,$port
$connection
.Connected
if ($connection.Connected) {Write-Host $ip : $port connected” -ForegroundColor Green}
else {Write-Host “$ip : $port not connected” -ForegroundColor Red}
$connection
.Close()

never forget to close your connection 🙂
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *