Powershell: Active Directory Domain Operations


some commands to manage Active Directory Domain Controllers by using the .NET System.DirectoryServices.ActiveDirectory.Domain Class.
Load the assembly


Get a Domain Object with the logon Domain of the current user


or get a Domain Object with the Domain of the computer


Get Domainmode and role owners…

write-host " Domain mode:             " $oADDomain.DomainMode
write-host " PDC Emulator:            " $oADDomain.PdcRoleOwner
write-host " Infrastructure master:   " $oADDomain.InfrastructureRoleOwner
write-host " Relative ID (RID) master:" $oADDomain.RidRoleOwner
write-host " Parent domain:           " $oADDomain.parent
write-host " Subdomains(if there are):" $oADDomain.children

Get a list of all Domaincontrollers


The following command shows a list of all DC’s with its Name and IP Address
Possibly other properties are

$coDCs|Format-Table -Property Name,IPAddress

List all trusted domains with trust-type and trustdirection

$oADDomain.GetAllTrustRelationships()| format-table

Get informations of specific trust


Is the inbound trust relationship of domain a selective one



Advertisment to support michlstechblog.info

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.