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