≡ Menu

PowerShell: Get Domain NetBIOS name from FQDN

How to find NetBIOS name of a Active Directory domain if you know the FQDN is something we will explore in this post. There are multiple ways to achieve this and let us see two of the popular and easy ways to do it.

We can get this information using two ways.

  1. Using Active Directory PowerShell cmdlet Get-ADDomain
  2. Using [ADSI] Powershell accelerator

Using Get-ADDomain.

To use this cmdlet you should have ActiveDirectory module installed as Get-ADDomain is part of this module. Once the module is imported with Import-Module cmdlet, you can get the NetBIOS domain name by passing FQDN as shown below.

Import-Module ActiveDirectory
(Get-ADDomain -Server techibee.local).NetBIOSName

Using [ADSI] PowerShell accelerator

Getting the NetBIOS name using Get-ADDomain cmdlet is very straightforwad and easy, but you cannot have this module installed on all the machines you want to run your script from. For example, you are scheduling a script on all computers in your environment in which you want to get the NetBIOS name, then it is practically impossible to deploy/maintain the module on all computers. Also this module requires Active Directory Web Services to be available which is available from Windows 2008 R2 onwards. If your domain has legacy DCs, Get-ADDomain will not work for you. The below sample code will help you such situations. It don’t have any dependency on the external modules, it relies on .Net classes to get the NetBIOS name from domain FQDN

([ADSI]"LDAP://techibee.local").dc

Do you know any other easy way? Please write in the comments section. It will be added to this article.

 

Comments on this entry are closed.

  • Erich August 13, 2018, 8:19 pm

    Your ADSI instructions do not necessarily return the NETBIOS name. Most of the time, the “DC” name is the same as the NETBIOS name, but not always. Expanding the properties of the ADSI object, I don’t see the NETBIOS name as an option.

    • Wintel Rocks August 19, 2018, 7:36 pm

      Can you post the code you are trying? I am wondering why DC name is NetBIOS name as I am not using any DC in my code.

  • CJ December 18, 2020, 5:22 am

    Try this:

    $domain=Get-ADDomain
    $domain.split(“.”)[0]

  • CJ December 18, 2020, 5:24 am

    oops this is probably fastest…

    ((Get-ADDomain).Name)