如何使用Powershell将IP地址解析为Linux的主机名 [英] How to use powershell to resolve IP address to hostname for Linux

查看:137
本文介绍了如何使用Powershell将IP地址解析为Linux的主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在域中同时拥有Windows服务器和Linux服务器,我需要根据IP地址找到主机名.

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

当前,我正在使用[System.Net.Dns]::gethostentry('10.254.254.254').HostName来获取主机名.但这仅在目标计算机是Windows计算机时才有效.当目标计算机是Linux计算机时,此powershell脚本不起作用.

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.

有人可以帮忙建议如何使用Powershell将IP地址解析为Linux计算机的主机名吗?

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

谢谢!

推荐答案

将您的PS版本升级到5.1.

Upgrade your PS version to 5.1.

我在Win Srv 2012上运行5.1.14409.1005,它适用于Unix和Windows.

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

这篇关于如何使用Powershell将IP地址解析为Linux的主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆