Sometimes when we’re working with others to troubleshoot network nodes at remote sites we get limited information. It’s not uncommon to get an IP address of a device that isn’t responding and we are asked to begin troubleshooting from that point.

For example, suppose you get a trouble ticket asking you to look into a printer with the IP address 10.222.222.12. You’re trouble ticket might state the printer isn’t printing anything and no other information. Now obviously, we want to work with our colleagues that entered the ticket to provide more information and prevent tickets like that from coming up in the future. With just an IP, it’s very difficult to figure out what branch office we might be working with.

But, what if we could run a tool that returns the active directory site associated to the IP address we’re looking for?  This could provide some helpful insight to help you find the domain controllers, dhcp servers, and print servers for the site. Enter Get-ADSubnet!

To make this tool useful, we do need active directory sites subnets defined. Otherwise you won’t really get any useful information back. This tool can also help audit which subnets are associated to sites in AD.

Get-ADSubnetSiteExample
Example active directory site from my lab.

To continue with the example, here’s how we use the tool.


Get-ADSubnet 10.222.222.*

Then, Get-ADSubnet will look through active directory, find the site associated to the IP range you’re looking for, and return all subnets for that site.

Get-ADSubnetExample
Just like that!

Below is the code I’ve written for this purpose. If you have an existing PowerShell module library with functions for your help desk or junior admins, this might be a good addition to those modules.

The tools being developed on this blog are available on the PowerShell gallery here! This means to begin using the tool set, simply run the following command to install them.


Install-Module -Name ServerAdminCommon

If you have previously installed the toolset, you can update the tools using following command:


Update-Module -Name ServerAdminCommon

As with all of the modules on this blog, you can find this tool on my github page for the ServerAdminCommon tool set.

Enjoy!

Disclaimer: All scripts and other powershell references on this blog are offered “as is” with no warranty. While these scripts are tested and working in my environment, it is recommended that you test these scripts in a test environment before using in your production environment.