PowerTip: Use PowerShell to Resolve DNS Names

PowerTip: Use PowerShell to Resolve DNS Names

  • Comments 1
  • Likes

Summary: Use Windows PowerShell to find IP addresses for DNS names.

Hey, Scripting Guy! Question How can I use Windows PowerShell to resolve a DNS name to an IP address?

Hey, Scripting Guy! Answer With Windows PowerShell 4.0 in Windows 8.1, use the Resolve-DnsName command,
          and then select the IP4address from the results:

(Resolve-DnsName www.microsoft.com).ip4address

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Invoking the GetHostEntry method of the system.net.dns class could also do the trick.

    ([system.net.dns]::GetHostEntry("www.microsoft.com")).AddressList.IPAddressTostring