Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - retrieving domain info

Reply
 
Old 08-21-2008   #1 (permalink)
KeithK


 
 

retrieving domain info

The following will get the Domain for the Current User:
$domain = $env:UserDNSDomain
What will get the domain of the computer the script is run from?


My System SpecsSystem Spec
Old 08-21-2008   #2 (permalink)
RichS [MVP]


 
 

RE: retrieving domain info

Get-WmiObject -Class Win32_ComputerSystem

will return the domain among other stuff

(Get-WmiObject -Class Win32_ComputerSystem).Domain gives just the domain
--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"KeithK" wrote:
Quote:

> The following will get the Domain for the Current User:
> $domain = $env:UserDNSDomain
> What will get the domain of the computer the script is run from?
>
My System SpecsSystem Spec
Old 08-21-2008   #3 (permalink)
/\/\o\/\/ [MVP]


 
 

RE: retrieving domain info

there are more way's but an easy one using WMI would be :

(gwmi Win32_ComputerSystem).domain

Greetings /\/\o\/\/
http://thePowerShellGuy.com

"KeithK" wrote:
Quote:

> The following will get the Domain for the Current User:
> $domain = $env:UserDNSDomain
> What will get the domain of the computer the script is run from?
>
My System SpecsSystem Spec
Old 09-08-2008   #4 (permalink)
Shay Levy [MVP]


 
 

Re: retrieving domain info



[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain().Name


---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic

K> The following will get the Domain for the Current User:
K> $domain = $env:UserDNSDomain
K> What will get the domain of the computer the script is run from?


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
VBScript for retrieving user account info. from a domain controller VB Script
retrieving info General Discussion
Retrieving Info Vista General
Retrieving lost info Vista file management
Join Vista Machine to Domain - Need info from local profile Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46