≡ Menu

Find domain name from command line

We can find the domain name of a computer by running the following commnad from command line.

systeminfo | findstr /B /C:"Domain"

We can find the logged in user’s domain by using the environment variable ‘USERDOMAIN’. Command for this is given below.

echo %userdomain%

Note that the value in %USERDOMAIN% may not be the same as the one returned by systeminfo command. %USERDOMAIN% gives the domain name the user account belongs to, it could be different from the domain of the computer. Also, this may give you the NetBios name of the computer, not DNS/FQDN name.

Alternatively, we can use WMIC to retrieve domain name.

wmic computersystem get domain
22 comments… add one
  • BINISH

    Whatt is the command to view domain name in windows 7

    • Srini

      All the above commands work on Windows 7. WMIC one may/may not work depending on whether the edition of win7 you have supports it or not.

  • admin

    The systeminfo command given in this post works on Windows 7 also. I think copying the command from this page had some problem and it did not work. Have corrected it. It should work now.

  • me

    systeminfo | findstr Domain

    I see no reason for the /b /c:” “

    • admin

      /C may not be required. /b is required to avoid matches with the values for other fields of systeminfo command.

  • ak

    Thanks! Useful!! Keep it up your good work!!!

  • GDS

    Thanks for this! I needed to pull the domain for a powershell script for use on servers that didn’t have the ActiveDirectory module (and I wasn’t going to install it).

    This enabled me to grab the domain, then trim out the header and return in Powershell for my variable.

    Thanks again!

    GDS

  • KCBI

    This command returns domain or workgroup: net config workstation
    * If domain: “Workstation Domain DNS Name”
    * If group: “Workstation domain”

  • Benja_Ninja

    Get-WmiObject is not recognized as a command. Any help guys?

    • MYB

      Get-WmiObject is a PowerShell cmdlet. You need to use the command in the PowerShell Terminal. To do it in the CMD Terminal, you need to run the WMIC commands (as explained above)
      For example, “wmic computersystem get domain” (without quotes)

  • John C.

    Can someone please guide me on how to obtain the domain name of the servers remotely. I need to get the domain name for hunderds of servers.
    Is there a way to create a CSV file with the server names and create a batch file and run it to obtain this information?
    Any help would be highly appreciated.
    Thanks.

    • ANON

      wmic /node:”COMPUTERNAME” computersystem get domain

  • Deepak

    I am getting domain as workgroup. what’s wrong here?

    C:\>systeminfo | findstr /B /C:"Domain"
    Domain:                    WORKGROUP
    • Srini

      It means that your computer is not part of a domain but a workgroup. All the home computers are part of a workgroup.

  • amy

    what is domain for windows 8? i need it for change to administrator, it is will work?

  • Sokchea Heang

    thanks for share me the value knowledge

  • Eddie Kumar

    Excellent info and list of commands.. Thank you.

  • Michael Calvin

    Just type –> set user

    gives you the domain info without searching

    • sasank

      this cmdlet gave the correct output

  • EB

    set user only shows the domain of which the user is a member.
    NOT the computer’s domain. (This could be different).

    If so, the ‘wmic computersystem get domain’ is a working command.

  • Noob

    systeminfo | findstr /B /C:”Domain” depends on the OS language.
    if you have a german OS, it’s
    systeminfo | findstr /B /C:”Domäne” .
    But otherwise fine info.

  • Taha

    Try netplwiz

Cancel reply

Leave a Comment