First published on TechNet on Aug 20, 2012
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.
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.
To report the IP configuration for every DC in the forest, simply run the script with the –DCs switch.
.\IpInfoV2.ps1 -DCs
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”
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.
Doug Symalla
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.