问题
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!
回答1:
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.
来源:https://stackoverflow.com/questions/42014215/how-to-use-powershell-to-resolve-ip-address-to-hostname-for-linux