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
Whatt is the command to view domain name in windows 7
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.
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.
systeminfo | findstr Domain
I see no reason for the /b /c:” “
/C may not be required. /b is required to avoid matches with the values for other fields of systeminfo command.
Thanks! Useful!! Keep it up your good work!!!
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
This command returns domain or workgroup: net config workstation
* If domain: “Workstation Domain DNS Name”
* If group: “Workstation domain”
Get-WmiObject is not recognized as a command. Any help guys?
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)
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.
wmic /node:”COMPUTERNAME” computersystem get domain
I am getting domain as workgroup. what’s wrong here?
It means that your computer is not part of a domain but a workgroup. All the home computers are part of a workgroup.
what is domain for windows 8? i need it for change to administrator, it is will work?
thanks for share me the value knowledge
Excellent info and list of commands.. Thank you.
Just type –> set user
gives you the domain info without searching
this cmdlet gave the correct output
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.
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.
Try netplwiz