Quantcast
Viewing all articles
Browse latest Browse all 18

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:

[System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()

Image may be NSFW.
Clik here to view.
ComputerDomainName

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

[System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties().DomainName

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

Share


Viewing all articles
Browse latest Browse all 18

Trending Articles