Powershell
Get domain info
This example shows how you can use the System.DirectoryServices.ActiveDirectory class from
the .NET framework to return information about the domain you are logged on to.
$myforest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() $myforest cls $dom = [System.DirectoryServices.ActiveDirectory.Domain]::getcurrentdomain() $dom | Format-List * #All info Write-Host ************************************************* write-host "Current domain name:" $DomInf.Name write-host "Domain mode:" $DomInf.DomainMode write-host "Domain controllers:" $DomInf.DomainControllers Write-host "PDC Role:" $dom.PdcRoleOwner.Name Write-host "Infrastructure Role:" $dom.InfrastructureRoleOwner.Name Write-host "RID Role:" $dom.RidRoleOwner.Name Write-host "Schema role:" $dom.Forest.SchemaRoleOwner Write-host "Naming role:" $dom.Forest.NamingRoleOwner Write-host "Global catalog's:" $dom.Forest.GlobalCatalogs Write-Host ************************************************* Write-host "Domains in this forrest:" $dom.Forest.Domains Write-host "Sites in this forrest:" $dom.Forest.Sites
Last Updated (Wednesday, 13 May 2009 16:23)