Home / HomePage / Scripts / FQDN

FQDN


Here is a simple script to get the FQDN (fully qualified domain name, ie somehost.somedomain.com) of a Windows system via WMI.

Note that it is possible for different NICs to have different DNS suffixes attached, so we loop through them all. To remove the display of NICs with no DNS name, just comment out the ELSE clause.

  1. strComputer = "."
  2. Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  3. Set colNICInfo = oWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
  4. For Each oNICProp in colNICInfo
  5.   If Not oNICProp.DNSHostName = "" Then
  6.     wscript.StdOut.Write oNICProp.Caption
  7.     wscript.StdOut.WriteLine " --> " & oNICProp.DNSHostName & "." & oNICProp.DNSDomain
  8.   Else
  9.     wscript.StdOut.Write oNICProp.Caption
  10.     wscript.StdOut.WriteLine " -->  adapter not configured"
  11.   End If
  12. Next

                  

Post a comment

Your Name or E-mail ID (mandatory)

 



 RSS of this page