1

We have both Windows servers and Linux servers in the domain, and I would need to find the hostname based on ip address.

Currently I am using [System.Net.Dns]::gethostentry('10.254.254.254').HostName to get the hostname. But this only work when target machine is windows machine. When the target machine is Linux machine, this powershell script doesn't work.

Can someone please help to advise how to use powershell to resolve IP address to hostname for Linux machine?

Thanks!

Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
fall
  • 11
  • 2
  • http://stackoverflow.com/a/32662358/478656 - it looks like the .Net method in your code connects to the remote machine to get the hostname, and doesn't use DNS. – TessellatingHeckler Feb 02 '17 at 23:41
  • Do you have `PTR` entries setup in DNS for your Linux systems? – TravisEz13 Feb 03 '17 at 00:47
  • I don't manage the network or the system. So I tried dig -x ip on those linux servers and I do see PTR section as result. – fall Feb 03 '17 at 16:05

1 Answers1

0

Upgrade your PS version to 5.1.

I am running 5.1.14409.1005 on Win Srv 2012 and it works for both Unix and Windows.

Moses
  • 1