perform nslookup from PowerShell

不想你离开。 提交于 2019-12-04 19:31:43

If you install the PSCX module, it comes with a cmdlet Resolve-Host which handles name lookups.

Absent that, this one-liner will do the job

[System.Net.Dns]::GetHostAddresses("www.msn.com")

You can also pass in an IP address - but the results will be different.

See also http://blogs.msdn.com/b/powershell/archive/2006/06/26/647318.aspx & http://powershell.com/cs/media/p/210.aspx

PowerShell 3.0 on Windows 8 and higher comes with a Resolve-DnsName cmdlet that will get this information:

(Resolve-DnsName $server_name)[0].IpAddress

Simply use :

Resolve-DnsName monServer | ? { # make selection here } | % { $_.IPAdress }  | select-object -first 1
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!