DC's in daom by IP and Name

Easy one, I know there must be a fast way to pull all the DC's in my domain (children also pls) and their IP's.  It must be in DNS, and an adsi command or something.
LVL 11
loftywormAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

David Johnson, CD, MVPOwnerCommented:
$DCS = Get-ADComputer -Filter * -SearchBase "OU=Domain Controllers,DC=corp,DC=Example,DC=com" 
foreach ($DC in $DCS){
Resolve-DnsName -Name $dc.Name -Type A | Select Name,IPAddress
}

Open in new window

loftywormAuthor Commented:
TY, you will get some point for certain, but here is another crux.
All the DC's may not be in that OU.  I strongly suspect I will have to pull the information from DNS (not all have NS records though, by design) or Sites and Services.
Aaron TomoskyDirector of Solutions ConsultingCommented:
modifying davids command to pull domain controllers instead of computers filtered to an ou. I don't have a forest to test this on though, it might do the same thing, but at least you don't have to fill in the searchbase

$DCS = Get-ADDomainController -Filter *
foreach ($DC in $DCS){
Resolve-DnsName -Name $dc.Name -Type A | Select Name,IPAddress
}

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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

loftywormAuthor Commented:
very VERY nice :)
Saved me BUNCHS of work :)

Thank you both so much, wish I could give out more then 500 points!
loftywormAuthor Commented:
Very nice, :)
loftywormAuthor Commented:
ok, this is awesome, but one last question.
On my 2008 DC's in my other domain's, the resolve-dns command is not present.  So
How do I add it?
or
How do I change the domain request from the DC that I have that works?
Aaron TomoskyDirector of Solutions ConsultingCommented:
I don't have an 08 to test on, but you can install newer powershell if you want
http://www.microsoft.com/en-us/download/details.aspx?id=34595

this is the command for powershell 2.0
[Net.DNS]::GetHostEntry("MachineName")

so to integrate it back into the script, but I can't test it so I'm not sure the syntax is correct:
$DCS = Get-ADDomainController -Filter *
foreach ($DC in $DCS){
[Net.DNS]::GetHostEntry("$dc.Name")
}

Open in new window

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.