How to Create a Microsoft DHCP Lease Inventory Script
Large organizations typically have lots of devices that require IP addresses. Client desktops, tablets, mobile and desk phones, servers and more all consume IPs. The only way to manage IPs at this level is to use Microsoft Dynamic Host Configuration Protocol (DHCP), which will also manage which devices obtain which IPs through DHCP leases. Even though the DHCP server in Microsoft Windows handles the majority of the work for you, you’ll occasionally need to run reports and query the current status of a device’s DHCP lease across multiple DHCP servers and scopes.
In this article, I’ll show you how to create a script in PowerShell that will allow you to discover all Microsoft DHCP servers in an Active Directory (AD) domain, all scopes on all of those servers and all leases inside those scopes. This will provide you with a simple way to run point-in-time DHCP lease reports and to easily query all DHCP leases in your organization for leases matching specific criteria.
- Before we get started, I’m going to assume a few things:
- You have PowerShell v4+ installed on the computer on which you’re running the script
- Your computer is in an Active Directory domain
- You have the Remote Server Administration tools package installed with the DHCP server module enabled
- You have all the appropriate rights to enumerate DHCP leases in your environment
Read the full article at Ipswitch.