Finding Your Current Domain

by Jul 21, 2010

Try this quick and simple way to find out the domain name that you are currently connected:


The domain name is returned if you are currently connected to a domain. Otherwise, you will receive an exception. You can also return arbitrary messages when not connected to a domain by adding an error handler:

try { [ADSI]"" | Out-Host } catch { "Not connected to a domain" }

Twitter This Tip! ReTweet this Tip!