We help IT Professionals succeed at work.

Powershell or methods to determine the number of AD forest & Domain ?

1,791 Views
Last Modified: 2017-04-18
Hi All,

I'm currently performing audit from one company to another and I'd like to know if there is any way to show how many AD forest and domains in the company ?

It can be a PowerShell script or GUI console step-by-steps.

Thanks in advance.
Comment
Watch Question

Schnell SolutionsSystems Infrastructure Engineer
CERTIFIED EXPERT

Commented:
It will be difficult to get the list of 'forests' because there is not one specific and reliable point of reference to get that information from. Many options could arise that can let you know about the existence of other forests but they will not mean that all of them are going to be necessary listed. It will be too crazy (Network traffic, review trust relationships from the domain, etc... and anyway that will not include all the information).

One very simple way to get the amount of domains within a single forest is using the command:

(Get-ADForest).Domains
This command will give you the list of domains

And with a slight change you can get the amount in numbers
((Get-ADForest).Domains).Count

These commands are assuming that you are using PowerShell with the active directory module installed. i.e. From a DC or a domain member computer with the consoles installed.
Senior IT System EngineerSenior Systems Engineer
CERTIFIED EXPERT

Author

Commented:
Hi Schnell,

When I viewed the AD user and console, in the Find dialog, I can see there are three domains in the drop down under the All Directories ?

but the AD Powershell above only returns just one.
Schnell SolutionsSystems Infrastructure Engineer
CERTIFIED EXPERT

Commented:
Can you confirm if these domains belong to the same forest? I wonder if they are domains that belong to a different forest and they are listed there as part of a domain trust.
Schnell SolutionsSystems Infrastructure Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Senior IT System EngineerSenior Systems Engineer
CERTIFIED EXPERT

Author

Commented:
Hi Schnell.

Can you confirm if these domains belong to the same forest? I wonder if they are domains that belong to a different forest and they are listed there as part of a domain trust.

Not sure with that since I'm in a new company here.

how to look into that ?
Schnell SolutionsSystems Infrastructure Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Senior IT System EngineerSenior Systems Engineer
CERTIFIED EXPERT

Author

Commented:
Ok, so here's the result:

Trust topology information obtained from the computer AdminLaptop007 in the domain MyDomain.com on 04/19/2017 12:09:26. 
This text file contains information on all trusts: Forest, External, Shortcut and ParentChild.
There are 2 forest trusts.
There are 0 internal (intra forest) trusts.
There are 0 external trusts.
**********************************************************************************************
Active Directory Trusts for Trusts of Type internal
*********************************
Active Directory Trusts for Trusts of Type forest
*********************************


Trust Name                                        : Trust Details for MyDomain.com|UnityNetwork.int
Local Domain (Source)                             : MyDomain.com
Trusted Domain (Target)                           : UnityNetwork.int
Trust Direction                                   : Bidirectional
Trust Type                                        : Forest
Trusted Domain Info: UnityNetwork                 : DNSName UnityNetwork.int | Domain SID: S-1-5-21-1907921415-2437651183-2526027976
Trust TopLevelNames (Name Suffix Routing)         : {UnityNetwork.int}
Trust Excluded TopLevelNames(Name Suffix Routing) : None Defined
Quarantine (SIDFiltering)                         : True
Selective Authentication                          : False





Trust Name                                        : Trust Details for MyDomain.com|MyPaymentSolution.com
Local Domain (Source)                             : MyDomain.com
Trusted Domain (Target)                           : MyPaymentSolution.com
Trust Direction                                   : Bidirectional
Trust Type                                        : Forest
Trusted Domain Info: MyPaymentSolution            : DNSName MyPaymentSolution.com | Domain SID: S-1-5-21-2000478354-1060284298-839522115
Trust TopLevelNames (Name Suffix Routing)         : {MyPaymentSolution.com}
Trust Excluded TopLevelNames(Name Suffix Routing) : None Defined
Quarantine (SIDFiltering)                         : True
Selective Authentication                          : False



Active Directory Trusts for Trusts of Type external
*********************************

Open in new window


Does this means there are three AD domains under single AD forest:

MyPaymentSolution.com <----Bi directional trust---->MyDomain.com<----Bi directional trust---->UnityNetwork.int
Systems Infrastructure Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Senior IT System EngineerSenior Systems Engineer
CERTIFIED EXPERT

Author

Commented:
Ah I see,

Schnell, there are 3 different AD forest and each forest contains single AD domain.
the trust is Bi directional so the AD login or account in MyPaymentSolution.com  is also recognized in UnityNetwork.int AD domain ?
Schnell SolutionsSystems Infrastructure Engineer
CERTIFIED EXPERT

Commented:
you are right !
Senior IT System EngineerSenior Systems Engineer
CERTIFIED EXPERT

Author

Commented:
Thanks!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.