gets basic domain information for currently logged on workstation


posted by Thomas Lee
12-28-2008

Downloads: 433
File size: 1.1kB
Views: 1,681

Embed
gets basic domain information for currently logged on workstation
  1. <# 
  2. .SYNOPSIS 
  3.     Shows use of GetCurrentDomain to return information about the domain 
  4. .DESCRIPTION 
  5.     Uses system.directoryservices.activedirectory.domain and GetCurrentDomain 
  6.     to return domain information  
  7. .NOTES 
  8.     File Name  : get-domain.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell V2 CTP3 
  11. .LINK 
  12.     http://www.pshscripts.blogspot.com 
  13. .EXAMPLE 
  14.     PS c:\foo> .\get-domain.ps1 
  15.     You are connected to the cookham.net domain 
  16.     Role Holders in this domain: 
  17.       PDC Role Holder     :  Cookham1.cookham.net 
  18.       RID Role Holder     :  Cookham1.cookham.net 
  19.       InfraM Role Holder  :  Cookham1.cookham.net 
  20. #> 
  21.  
  22. ### 
  23. # Start of script 
  24. ### 
  25.  
  26. #Get Domain information 
  27.    $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()  
  28.  
  29. #Display information    
  30.    "You are connected to the {0} domain" -f $domain.name  
  31.    "Role Holders in this domain:" 
  32.    "  PDC Role Holder     :  {0}" -f $domain.PdcRoleOwner 
  33.    "  RID Role Holder     :  {0}" -f $domain.RIDRoleOwner 
  34.    "  InfraM Role Holder  :  {0}" -f $domain.InfrastructureRoleOwner 
  35. # End of script 
Filed under: ,
Gets domain name, plus domain FSMO role holders
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.