Get HostName for Each RemoteAddress IP in New Member


have powershell script, has variablie
1. $getcon : tcp connection in powershell
2. $hn : expand remote-address in $getcon.
3. $rrt : number of results, it's connection ip's.
4. $gnamess : variable create new member name (urls) for $getcon wich get-nettcpconnection. 
finally i have new member, contain list of each connections host names each ip address in get-tcpconnection remoteaddress.
but we don't revive result of host's in result, in result i've 1 host each host's!
please me method host's in result.

wrong syntax:

$getcon = get-nettcpconnection  $hn = $getcon | select -expand remoteaddress  $rrt = foreach ($ips in $hn) {   [system.net.dns]::gethostaddresses($ips) | select-object ipaddresstostring -expandproperty  ipaddresstostring  }   $gnamess = foreach ($ipst in $getcon) {      $rrt = ([system.net.dns]::gethostbyaddress($ips) | select-object hostname -expandproperty  hostname)     $ipst | add-member -notepropertyname urls -notepropertyvalue $rrt -passthru }  $getcon | select urls

image result: https://i.stack.imgur.com/ov5ye.png


your script looks on place, you're adding new member called urls ipst, calling $getcon | select urls. doesn't make sense, trying do?

if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607