Finding Your Current Domain

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

[ADSI]""

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!


Posted Jul 21 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.