QuickTip: Get Domain Name of Computer

In PowerShell it is relatively trivial to retrieve the domain for the logged in user, as this is stored in the environment variable. In multi-domain environments it is often the case that the user account is a member of the same domain as the computer account. To retrieve the domain name of the current computer the following command can be executed:



To only retrieve the Domain Name the following command can be used:


For more information about the GetIPGlobalProperties method and the IPGlobalProperties class please refer to the following article:
MSDN – IPGlobalProperties


Leave a Reply