Powershell command to see all the domain/forest info

This one always frustrate me.  Simple command to see all the domain or forest details. And it doesn't show the list all the servers or sites.  
For example: Get-ADDomain | Format-List
Gives me
ReplicaDirectoryServers            : {server1.company.com, server2.company.com, server3.company.com, server4.company.com...}   how to get all servers?

Same for this:  Get-ADForest | Format-List

Gives me:
GlobalCatalogs        : {server1.company.com, server2.company.com, server3.company.com, server4.company.com...}  how to get all servers?
Sites                 : {site1, site2, site3, site4...} how to get all sites?

I'm probably missing something very simple.  Just annoying issue!
LVL 17
Tiras25Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
The result of a cmdlet are usually objects with multiple properties. These properties can contain arrays, for example, as is the case here. Format-List will stop at some point in enumerating an array, as you can see.
Answer us easy: expand the property you want to see:
Get-ADDomain | Select-Object -ExpandProperty ReplicaDirectoryServers
Get-ADForest | Select-Object -ExpandProperty GlobalCatalogs

Open in new window

Hint: above is for use in a script, when you should use no aliases and full argument names for readability.
For a quick one-liner in the console, you can shorten that (even the property, as long as there's only one result when the wildcard is evaluated):
Get-ADDomain | select -expa Repl*

Open in new window

Or access the property
(Get-ADDomain).ReplicaDirectoryServers
(Get-ADForest).GlobalCatalogs

Open in new window

Or save in a variable and access the properties:
$adDomain = Get-ADDomain
$adDomain.ReplicaDirectoryServers

Open in new window

In the console, the last method has the advantage that PS knows the variable type, and you can use tab completion when typing the property name:
$adDomain = Get-ADDomain
$adDomain.Repl<tab>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jose Gabriel Ortega CastroEE Rookie/Solution Guide/Topic Advisor and CEO Faru Bonon ITCommented:
Or you can show them as, comma separated values like this:
@{Name = 'Name'; Expression = {$_.Name}}

#create a custom property, and transfor the Object into string, then just expand it
Get-ADForest | Select @{n="GlobalCatalogs";e={$_.GlobalCatalogs -join ","}} | select -ExpandProperty  GlobalCatalogs

#create a custom property called ReplicaDirectoryServers, (n from name and e from expression), , and transform the Object into string, then just expand it
 Get-ADDomain | Select @{n="ReplicaDirectoryServers";Expression={$_.ReplicaDirectoryServers -join ","}} | select -ExpandProperty  ReplicaDirectoryServers

Open in new window

Tiras25Author Commented:
I knew I had to narrow it down.  Didn't know how.  
Thanks guys!
Shaun VermaakTechnical SpecialistCommented:
Also, look at the Get-ADDomain and Get-ADForest part of the sample report in this article
https://www.experts-exchange.com/articles/33488/Computer-Audit-with-Powershell.html?headerLink=workspace_article
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.