2

I found this question for getting FQDN of localhost. My question is, is there any way to get the FQDN of machine which is not in same domain as host machine where we query in c#.

For eg: on machineA (in Domain A) runs a program to find out FQDN of machineB (in Domain B).

Community
  • 1
  • 1
Mahender
  • 5,554
  • 7
  • 38
  • 54

1 Answers1

4

In C# (.NET) you can call

var fqdn = System.Net.Dns.GetHostEntry("host-name-goes-here").HostName

Almost the same for powershell

$fqdn = [System.Net.Dns]::GetHostEntry("host-name-goes-here").HostName
Daniel Fisher lennybacon
  • 3,865
  • 1
  • 30
  • 38
  • Very useful, just a hint - if you want the FQDN of the current machine you can say: `System.Net.Dns.GetHostEntry(Environment.MachineName).HostName; ` – Matt Feb 03 '16 at 16:19