I use a powershell login script to find the ip address for printing purposes. Essentially I find the connection using the pcoip port and go backwards. Maybe you can do something with that.
$a = [System.Net.NetworkInformation.IpGlobalProperties]::GetIPGlobalProperties().GetActiveTcpConnections()
foreach ($connection in $a) {
$port = $connection.localendpoint.port
if ($port -eq "4172")
{
}
}