≡ 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.

Using WMIC

Alternatively, we can use WMIC to retrieve domain name.

wmic computersystem get domain

Using Powershell command

14 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?

  • 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?

Leave a Comment