Always A-HEAD, By being ahead you are always master of time

Hits

BOOKS

Sunday, February 18, 2007

AD Infrastructure from No Man's Land View

There are people who knows why it happens, there are people who explain how to make it happen and there are people who use the above two concept for their own customization.

Suppose one day your manager asks to get over to the role of Active directory team lead. First question that comes to mind, is there any AD Infra documentation about it, In most case it is not. But with powershell by your side, it is simple to get these details. Lets start with Forest

 

$forest=[system.directoryservices.activedirectory.forest]::getcurrentforest()
write-host ""
Write-Host "Forest Mode :" $forest.Get_forestmode()
write-host ""
Write-Host SCHEMA ROLE OWNER
$forest.SchemaRoleOwner | select Name,Domain,IPAddress,sitename,OSVersion
if($forest.SchemaRoleOwner.IsGlobalCatalog()) {write-host $forest.SchemaRoleOwner.name is GC}
write-host ""
Write-Host NAMING ROLE OWNER
$forest.namingRoleOwner | select Name,Domain,IPAddress,sitename,OSVersion
if($forest.namingRoleOwner.IsGlobalCatalog()) {write-host $forest.namingroleowner.name is GC}
write-host ""
Write-host "SITES AND ITS LOCATION"
$forest.Sites | %{$_.name,$_.location}
Write-host "Number of sites "$forest.Sites.Count
#Global Catalogs
Write-host Number of GC : $forest.FindAllGlobalCatalogs().count
write-host ""
Write-Host "ALL GC'S NAME"
$forest.FindAllGlobalCatalogs() | %{$_.name}

OUTPUT:

Forest Mode : Windows2000Forest

SCHEMA ROLE OWNER

Name : snguatser.Zarays.com
Domain : Zarays.com
IPAddress : 192.168.100.110
SiteName : Default-First-Site-Name
OSVersion : Windows Server 2003

snguatser.Zarays.com is GC

NAMING ROLE OWNER
Name : snguatser.Zarays.com
Domain : Zarays.com
IPAddress : 192.168.100.110
SiteName : Default-First-Site-Name
OSVersion : Windows Server 2003

snguatser.Zarays.com is GC

SITES AND ITS LOCATION
Default-First-Site-Name
Number of sites 1
Number of GC : 1

ALL GC'S NAME
snguatser.Zarays.com

-----------------------------------------------------------------------------------

 

$domain=[system.directoryservices.activedirectory.domain]::getcurrentdomain()
Write-host Domain_Name: $domain.name
write-host Forest_Name : $domain.Forest.name
write-host Domain_Mode: $domain.DomainMode

Write-Host (""*25 + "Domain Controllers" + ""*25)
Write-Host Number of DC : $domain.DomainControllers.Count
Write-Host Domain controllers details:->
$domain.DomainControllers | %{$_.name,$_.IPAddress,$_.sitename,$_.osversion}
write-host ("-"*60)
Write-Host "Infrastructure Master Role :"
$domain.InfrastructureRoleOwner | fl Name,OSVersion,IPAddress,Sitename
if($domain.InfrastructureRoleOwner.IsGlobalCatalog()) {write-host $domain.InfrastructureRoleOwner.name is Global Catalog}
write-host (""*60)
Write-Host "PDC Master Role :"
$domain.pdcRoleOwner | fl Name,OSVersion,IPAddress,Sitename
if($domain.PDCRoleOwner.IsGlobalCatalog()) {write-host $domain.PDCRoleOwner.name is Global Catalog}
write-host (""*60)
Write-Host "RID Master Role :"
$domain.ridRoleOwner | fl Name,OSVersion,IPAddress,Sitename
if($domain.ridRoleOwner.IsGlobalCatalog()) {write-host $domain.ridRoleOwner.name is Global Catalog}
write-host""

OUTPUT:

Domain_Name: Zarays.com
Forest_Name : Zarays.com
Domain_Mode: Windows2000NativeDomain
Domain Controllers
Number of DC : 1
Domain controllers details:->
snguatser.Zarays.com
192.168.100.110
Default-First-Site-Name
Windows Server 2003
------------------------------------------------------------
Infrastructure Master Role :

Name : snguatser.Zarays.com
OSVersion : Windows Server 2003
IPAddress : 192.168.100.110
SiteName : Default-First-Site-Name

snguatser.Zarays.com is Global Catalog

PDC Master Role :

Name : snguatser.Zarays.com
OSVersion : Windows Server 2003
IPAddress : 192.168.100.110
SiteName : Default-First-Site-Name

snguatser.Zarays.com is Global Catalog

RID Master Role :

Name : snguatser.Zarays.com
OSVersion : Windows Server 2003
IPAddress : 192.168.100.110
SiteName : Default-First-Site-Name

snguatser.Zarays.com is Global Catalog

That's all for this post. It is simple idea what you can idea from CMDlets without even going through all places collecting and documenting this information. SInce my test machine doesn't include multiple domains, I can really get hold of better formatting.

1 comment:

Amitabh Dey said...

Nice one! Quite useful!