Quantcast
Channel: SQL Server DBA
Viewing all articles
Browse latest Browse all 80

How to resolve a hostname or ip address with Powershell

$
0
0

Question: How can I use Powershell to return DNS information , specifically the fully qualified name of the server?

 

Answer: These are some examples you could incorporate into your Powershell Scripts

 

 

Method 1: Returns fully qualified name 

$SrvrName = [System.Net.Dns]::gethostentry("$SrvrIP") | Select HostName -ExpandProperty HostName

 

Method 2: Returns the fully qualified name of the server 

[System.Net.Dns]::GetHostEntry("$SrvrIP").HostName

 

Method 3:Returns Hostname, Aliases, Address List 

[System.Net.Dns]::GetHostEntry('google.com')

 

To get FQDN of multiple servers - How to get FQDN of multiple servers with Powershell


Viewing all articles
Browse latest Browse all 80