O R G A N I C / F E R T I L I Z E R: using powershell to list active directory trusts

Aug 31, 2009

using powershell to list active directory trusts

this is an easy concept to do for the current domain:

$myLocalDomain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()


$myLocalDomain.GetAllTrustRelationships()


 

it’s a little different if you want to do it for another domain, such as the root domain, for example:

$myRootDirContext = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext('domain',"myDomain.com")


$myRootDomain = [System.DirectoryServices.ActiveDirectory.Domain]::GetDomain([System.DirectoryServices.ActiveDirectory.DirectoryContext]$myRootDirContext)


$myRootDomain.GetAllTrustRelationships()