I am trying to query what domains are trusted by a particular domain. So, i figured to query a dc and ask it what domains it trusts and what direction they are.
i found the below script and it somewhat orks for me if i run it locally on the dc, but errors when run remotely. when done locally i get odd output that doesn't match what i expect to see (according to the KB article).
any ideas how i can get it to wortk remotely with me only having to change the target machine (which will always be a DC) to query?
strComputer = "dc name"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\MicrosoftActiveDirectory")
Set colTrustList = objWMIService.ExecQuery _
("Select * from Microsoft_DomainTrustStatus")
For each objTrust in colTrustList
Wscript.Echo objTrust.TrustedDomain
Wscript.Echo objTrust.TrustDirection
Wscript.Echo objTrust.TrustType
Wscript.Echo objTrust.TrustAttributes
Wscript.Echo objTrust.TrustedDCName
Wscript.Echo objTrust.TrustStatus
Wscript.Echo objTrust.TrustIsOK
Next
thanks very much for any input.
Thanks,
i found the below script and it somewhat orks for me if i run it locally on the dc, but errors when run remotely. when done locally i get odd output that doesn't match what i expect to see (according to the KB article).
any ideas how i can get it to wortk remotely with me only having to change the target machine (which will always be a DC) to query?
strComputer = "dc name"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\MicrosoftActiveDirectory")
Set colTrustList = objWMIService.ExecQuery _
("Select * from Microsoft_DomainTrustStatus")
For each objTrust in colTrustList
Wscript.Echo objTrust.TrustedDomain
Wscript.Echo objTrust.TrustDirection
Wscript.Echo objTrust.TrustType
Wscript.Echo objTrust.TrustAttributes
Wscript.Echo objTrust.TrustedDCName
Wscript.Echo objTrust.TrustStatus
Wscript.Echo objTrust.TrustIsOK
Next
thanks very much for any input.
Thanks,