Computer Name, DNS Name, and IP Address

by Mar 1, 2019

Here is a simple one-liner that returns your computers’ current IP address and its full DNS name:

PS> [System.Net.Dns]::GetHostEntry('')

HostName        Aliases AddressList                                
--------        ------- -----------                                
DESKTOP-7AAMJLF {}      {fe80::532:c4e:c409:b987%18,}

To examine a remote machine, simply submit the computer remote name instead of an empty string:

PS> [System.Net.Dns]::GetHostEntry('')

HostName      Aliases AddressList                                                   
--------      ------- -----------                                           {}      {,,,}

If you just would like to get the list of assigned IP addresses, try this:

PS> [System.Net.Dns]::GetHostEntry('').AddressList.IPAddressToString 

Your learning points:

  • The System.Net.DNS class contains a number of useful DNS-related methods. GetHostEntry() is especially useful because it accepts both computer names and IP addresses and returns the corresponding DNS names and IP addresses.
  • Submit an empty string to view your machines’ own settings – PowerShell Conference EU 2019 – June 4-7, Hannover Germany – visit There aren’t too many trainings around for experienced PowerShell scripters where you really still learn something new. But there’s one place you don’t want to miss: PowerShell Conference EU – with 40 renown international speakers including PowerShell team members and MVPs, plus 350 professional and creative PowerShell scripters. Registration is open at, and the full 3-track 4-days agenda becomes available soon. Once a year it’s just a smart move to come together, update know-how, learn about security and mitigations, and bring home fresh ideas and authoritative guidance. We’d sure love to see and hear from you!

Twitter This Tip! ReTweet this Tip!