Enviar la posición del ratón constantemente entre dos equipos utilizando el protocolo UDP desde PowerShell

Equipo 1 (servidor)

##Server

$ip = New-Object System.Net.IPEndPoint ([IPAddress]::Any,0)
$udp = New-Object System.Net.Sockets.UdpClient 2020
   
do{
    try
    {
        $content = $udp.Receive([ref]$ip)
        $posicion = [Text.Encoding]::ASCII.GetString($content)
        $posicion
    }
    catch
    {
    }
}while($posicion.split(",")[0] -ne 0)

$udp.Close()

Equipo 2 (cliente)

## Cliente

$ip = New-Object System.Net.IPEndPoint ([IPAddress]::Loopback,2020)
$udp = New-Object System.Net.Sockets.UdpClient
   
do{
    try
    {
        $posicion = [String]([System.Windows.Forms.Cursor]::Position.X) `
        + "," + [String]([System.Windows.Forms.Cursor]::Position.Y)
        $posicion
        $mensaje = [Text.Encoding]::ASCII.GetBytes($posicion)
        $udp.Send($mensaje,$mensaje.length,$ip) | Out-Null
    }
    catch
    {
    }
}while($posicion.split(",")[0] -ne 0)


$udp.Close()

Resultado gráfico