Wednesday 17 December 2008

Get-FSMOHolders.ps1

  1. # Get-FSMOHolders.ps1 
  2. # Gets the names of the systems holding the 5 FSMO holders 
  3. # Runs on a domain-joined machine 
  4. # Thomas Lee - tfl@psp.co.uk 
  5.  
  6. # Get host,forest and domain details 
  7. $Hostname   = hostname 
  8. $forest = [DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 
  9. $domain = [DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() 
  10.  
  11. #Display FSMOs, forest wide first 
  12. "For Host {0}" -f $hostname 
  13. "In Forest {0}, forest masters are: " -f $for.name 
  14. "Schema master          : {0}" -f $forest.SchemaRoleOwner.Name 
  15. "Domain Master          : {0}" -f $forest.NamingRoleOwner.Name 
  16. "" 
  17. # Current domain 
  18. "In domain {0}, domain masters are:" -f $dom.Name 
  19. "PDC Master            : {0}" -f $domain.PdcRoleOwner 
  20. "Infrastructure Master : {0}" -f $domain.InfrastructureRoleOwner 
  21. "RID Master            : {0}" -f $domain.RidRoleOwner 

This code produces the following output:

PS C:\foo> .\Get-FSMOHolders.ps1
For Host Cookham8
In Forest cookham.net, forest masters are:
Schema master          : Cookham1.cookham.net
Domain Master          : Cookham1.cookham.net

In domain cookham.net, domain masters are:
PDC Master            : Cookham1.cookham.net
Infrastructure Master : Cookham1.cookham.net
RID Master            : Cookham1.cookham.net

No comments: