Skip to content

Instantly share code, notes, and snippets.

@jongyllen
Created November 2, 2015 19:18
Show Gist options
  • Save jongyllen/9f21f81d203cfb583a5a to your computer and use it in GitHub Desktop.
Save jongyllen/9f21f81d203cfb583a5a to your computer and use it in GitHub Desktop.
param(
[parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string]
$data,
[parameter(Mandatory=$false, ValueFromPipeline=$true)]
[string]
$ip="127.0.0.1",
[parameter(Mandatory=$false, ValueFromPipeline=$true)]
[int]
$port=9999
)
$ipAddress=[System.Net.IPAddress]::Parse($ip)
$endPoint=New-Object System.Net.IPEndPoint($ipAddress, $port)
$udpclient=New-Object System.Net.Sockets.UdpClient
$encodedData=[System.Text.Encoding]::ASCII.GetBytes($data)
$bytesSent=$udpclient.Send($encodedData,$encodedData.length,$endPoint)
$udpclient.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment