22 January,2013 by Jack Vamvas
Question: How can I obtain the Fully Qualified Domain Name (FQDN) of the local and remote servers using Powershell?
how can I obtain the IP address of the server?
Answer: In powershell there are a number of different methods. The most effective is using the System.Net.Dns class. These examples illustrate the ease of use to obtain FQDN and IP address for local and remote servers.
#Get the FQDN of the local server "$env:computername.$env:userdnsdomain" #Get the FQDN of the local server [System.Net.Dns]::GetHostByName(($env:computerName)) #Get the FQDN of the IP address for remote server [System.Net.Dns]::GetHostByName("server1") [System.Net.Dns]::GetHostByName("server2") #Get the IP address of the FQDN [System.Net.Dns]::GetHostAddresses("server3")
To get FQDN of multiple servers - How to get FQDN of multiple servers with Powershell