- <#
- .SYNOPSIS
- Shows use of GetCurrentDomain to return information about the domain
- .DESCRIPTION
- Uses system.directoryservices.activedirectory.domain and GetCurrentDomain
- to return domain information of the currently logged on user. Note that this
- domain may be different to the domain of the computer itself.
- .NOTES
- File Name : get-domain.ps1
- Author : Thomas Lee - tfl@psp.co.uk
- Requires : PowerShell V2 CTP3
- .LINK
- http://www.pshscripts.blogspot.com
- .EXAMPLE
- PS c:\foo> .\get-domain.ps1
- You are connected to the cookham.net domain
- Role Holders in this domain:
- PDC Role Holder : Cookham1.cookham.net
- RID Role Holder : Cookham1.cookham.net
- InfraM Role Holder : Cookham1.cookham.net
- #>
- ###
- # Start of script
- ###
- # Get Domain information
- $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
- # Display information
- "You are connected to the {0} domain" -f $domain.name
- "Role Holders in this domain:"
- " PDC Role Holder : {0}" -f $domain.PdcRoleOwner
- " RID Role Holder : {0}" -f $domain.RIDRoleOwner
- " InfraM Role Holder : {0}" -f $domain.InfrastructureRoleOwner
- # End of script
This blog contains PowerShell scripts, more PowerShell scripts and still more PowerShell scripts. Occasionally you may see some organisational posts.
Thursday 1 January 2009
Get-Domain
Subscribe to:
Post Comments (Atom)
2 comments:
You probably should use GetComputerDomain() instead of GetCurrentDomain(). The one you used returned the domain of the currently logged in user instead of domain the computer joined to.
The script was meant to show the use of GetCuttentDomain. I have entered a separate script for GetComputerDomain. Thanks for the heads up!
Post a Comment