Finding what Active Directory sites do not have domain controllers

Dear guys,
I hope you are all well.

We often have the issue whereby for whatever reason, we may go into AD sites and subnets, and find that a domain controller does not exist for a site.

What I woukd like to do is the following:
Build a query that:

1) Returns a list of all AD sites
2) For each site, query the presence of an NTDS settings object
3) Depending on the outcome of step 2), write the site name to one of 2 possible files:

Site-dc-yes.txt

Or

Site-dc-no.txt

So, for example, a site that has no NTDS settings object means it has no domain controller, so write its site name to the file: Site-dc-no.txt

Any help greatly appreciated.
LVL 1
Simon336697Asked:
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.

JaihuntCommented:
Command to find all DCs in the given site

>>dsquery server -o rdn -site <site name>

Command to find all DCs in the Forest

>>dsquery server -o rdn -forest

Reference

http://social.technet.microsoft.com/wiki/contents/articles/2195.active-directory-dsquery-commands.aspx
0

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
SubsunCommented:
Try this PowerShell code.. it will export the required details to csv file..
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites | Select Name,@{N="DC's";E={$_.Servers -join ","}},@{N="DC Count";E={($_.Servers | Measure).Count}} | Export-Csv C:\report.csv -NTI

Open in new window

0
SandeshdubeySenior Server EngineerCommented:
You can also use dsquery server -forest to list the servername with site name.It will not list the empty site.
0
Simon336697Author Commented:
Thanks so much
0
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
Active Directory

From novice to tech pro — start learning today.