Get all DCs in a forest and resolve hostname to IP address

Get all DCs in a forest and resolve hostname to IP address

With this script, you will be able to get all DCs in a forest and resolve the hostnames to IP addresses.

Update 11.22.2016
The DNS Shell cmdlet is not necessary in a Windows 2012R2 environment. We can use the cmdlet resolve-DnsName to do the job. The script is now the following

Old script version for Windows OS 2008R2 and older
The pre-requesite to run this script is to install the DNS Shell cmdlets (

Script :


DNS Shell cmdlets

DnsShell is a Microsoft DNS administration / management module written for PowerShell 2.0
Bugs, issues and suggestions

Please do report any and all bugs you experience using this module (or failing to use this module). Hopefully Discussions and Issue Tracker on here will allow that. If not, please drop a comment onto my blog (or e-mail me if you can guess my easy-to-guess address):

I’ll either raise it as an issue or fix it (depending on severity / difficulty).

The same applies for issues and suggestions.

Extract to one of the paths shown by $Env:PSModulePath
Run: Import-Module DnsShell

Notes (issues that will not effect module functionality):
Import-Module will throw an error on import if the Execution Policy requires all files to be signed. The format file is not signed.

DNS Resolver

WMI Wrappers

Active Directory


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Social Media Auto Publish Powered By :
%d bloggers like this: