Fellow PFE and blogger Michael “Hilde” Hildebrand makes a great case for being able to inventory the IP configuration of your hosts – especially those that have static IP configurations (like most of your servers). For example, audit the DNS server search order (primary and secondary DNS servers) across dozens of your servers. Based on my experiences, you’re likely to find a couple of systems with an invalid (or non-optimal) setting. This can happen because DNS servers have been migrated, or retired. Or it could happen, because someone has made a mistake when entering the data.
Undoubtedly, it is to your benefit to be able to audit the IP configuration across your hosts, and proactively search for potential problems. If you administer more than 5 systems, you would benefit from an automated way to do this.
Searching the web for PowerShell code to help in this situation reveals many examples. Here’s a blog that does a great job of explaining how to build the code. Taking it to the next level, I’ve developed a multi-function script that can help you audit your configuration, and even make potential changes.
Enter the Script – IPInfoV2.ps1. Reporting IP Configuration…
The script (IPInfoV2.ps1) is attached to this blog. Feel free to review, re-cycle and re-use the code. The usual terms apply. Here’s a quick primer on using the script to report IP configuration across multiple hosts.
- The script always requires at least one parameter (the scope of computers against which to run). Use one of the following switches to specify the scope:
- –DCs (all DCs in the forest), OR
- –Domain (all computers in the domain), OR
- –Inputfile <filename> (list of computers in filename), OR
- –BaseDN <DN> (all computers in AD container <DN> and sub-containers)
- The script will always report to screen. (Note that all columns may not fit on the screen).
- The script will always output results to a CSV file (IPInfo.csv), which is helpful for searching/filtering/sorting in Excel.
Example 1: Reporting IP Configuration Details for All DCs in the Forest
To report the IP configuration for every DC in the forest, simply run the script with the –DCs switch.
Using the Script to “Find” Hosts That Target a Specific DNS Server…
To find which hosts are pointing to a specific IP address for Primary, Secondary or Tertiary DNS use the switch -DNSServerfind (don’t forget the scope – see above for the four scopes).
For example, to examine all the computers in the file, servers.txt, and determine which are pointing to 10.10.193.67 as a DNS server (primary, secondary or tertiary), run:
.\IPInfoV2.ps1 –inputfile “C:\scripts\servers.txt” –DNSServerFind “10.10.193.67”
Enter at Your Own Risk – DNS Server Replace…
Note: Be sure you test and understand the implications of making a change to the DNS Server settings on a computer before using the replace functionality of the script.
To find which hosts are pointing to a specific IP address for Primary, Secondary or Tertiary DNS, AND to change that value to a different value, use the switch -DNSServerfind AND the switch -DNSServerReplace(don’t forget the scope – see above for the four scopes).
Note: The DNSServerReplace functionality will skip any computers/interfaces that use DHCP. The assumption is that the DHCP scope will assign the DNS server.
For example, to find all domain controllers that are using 10.10.193.67 for a DNS server (primary, secondary or tertiary) AND to replace that with 10.10.193.68, run:
.\IPInfoV2.ps1 –DCs –DNSServerFind “10.10.193.67” –DNSServerReplace “10.10.193.68”
Add this script to your toolset, and get on top of your IP configuration – DNS server search order, WINS server search order and NetBIOS settings. Enjoy.
Update (3.April.2013): To centralize the storage of all AskPFEPlat scripts, we are now storing them on the TechNet Script Center Repository. This specific script can be found at the following location: