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()
Great tip !! .. may i add this to my PowershellTips database ?
ReplyDeleteregards,
Bernard Flach
certainly, bernard. thanks for the comment!
ReplyDeleteJust added. Thanks !
ReplyDeletehttp://www.powershelltips.org/list-active-directory-trusts/
Just added. Thanks !
ReplyDeletehttp://www.powershelltips.org/list-active-directory-trusts/
nice tip, but...
ReplyDeletewe have like over 80 trusts (including NT trusts) and via that script i got only 47 (Outbound/Bidirectional/Inbound). i know, there are also some "not valid anymore", but i suppose, all trusts should be listed. any idea, what could be reason? thanx, Jiri
just small update. seems, like NT trusts couldnt be retrieved. trying to figure it out.
ReplyDeletedon't have any more of those unfortunately so i'm not sure what that's about. :/
ReplyDeleteI have the same issue with NT4 trusts. I have also used C# to attempt to list all the trusts. It seems as there is an issue with .Net listing the NT trusts. Has anyone figured out a solution using PS or C#?
ReplyDelete